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

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

NameTypeDescription
seednumber

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)

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