Reference · Streams, draws and seeds
countedfunction
A seeded stream that counts its own draws, so that it can be written down
at any moment and picked up later: const random = counted(42), draw from
it as from any stream, then keep random.position(). The numbers are those
of mulberry32(seed), draw for draw.
Import it
import { counted } from "@johnmorrisdotca/tane";
Definition
function counted(seed: number, draws?: number): CountedRandom
Parameters
| Name | Type | Description |
|---|---|---|
seed | number | The numeric seed, read as an unsigned 32-bit integer by the stream. |
draws (optional) | number | The nonnegative number of draws already consumed. |
Returns
CountedRandom
A seeded stream that counts its own draws, so that it can be written down at any moment and picked up later: const random = counted(42), draw from it as from any stream, then keep random.position(). The numbers are those of mulberry32(seed), draw for draw.
Examples
import { counted } from "@johnmorrisdotca/tane";
const position = { seed: 42, draws: 3 };
console.log(counted(42, 3).position());{ seed: 42, draws: 3 }What it prints (run when this page was built)