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

fromJSONfunction

A position from JSON that toJSON wrote. Nothing in it is trusted: the seed and the draws must be whole numbers in range, the algorithm (when named) must be mulberry32, and the state (when given) must be the one that seed and those draws come to. Null when the text is not JSON, is not a position, does not add up, or is of a later format than this version reads.

Import it

import { fromJSON } from "@johnmorrisdotca/tane";

Definition

function fromJSON(text: string): StreamPosition | null

Parameters

NameTypeDescription
textstring

Text to hash, validate or decode.

Returns

StreamPosition | null

A position from JSON that toJSON wrote. Nothing in it is trusted: the seed and the draws must be whole numbers in range, the algorithm (when named) must be mulberry32, and the state (when given) must be the one that seed and those draws come to. null when the text is not JSON, is not a position, does not add up, or is of a later format than this version reads.

Examples

import { fromJSON, toJSON } from "@johnmorrisdotca/tane";

const position = { seed: 42, draws: 3 };
console.log(fromJSON(toJSON(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.