Skip to the content

Tane種

Reproduce numbers from a seed, shuffle or pick items, share a daily puzzle and resume a saved stream.

Tane means seed in Japanese. About the name

Contents

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

NameTypeDescription
randomRandom

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.9250807701610029

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/tane 1.3.0.