Reference · Streams, draws and seeds
forkfunction
A new, independent stream split off another: it takes one draw from
random and seeds a fresh generator from it. Use it to hand a part of the
work its own stream, so drawing more there never shifts what comes after.
For a sub-stream named by a label rather than by order, use deriveSeed.
Import it
import { fork } from "@johnmorrisdotca/tane";
Definition
function fork(random: Random): Random
Parameters
| Name | Type | Description |
|---|---|---|
random | Random | A random source returning values in [0, 1). |
Returns
Random
A new, independent stream split off another: it takes one draw from random and seeds a fresh generator from it. Use it to hand a part of the work its own stream, so drawing more there never shifts what comes after. For a sub-stream named by a label rather than by order, use deriveSeed.
Examples
import { fork, mulberry32 } from "@johnmorrisdotca/tane";
console.log(fork(mulberry32(42))());0.9250807701610029What it prints (run when this page was built)