Reference · Streams, draws and seeds
toJSONfunction
A position as JSON, two spaces deep, with the format's number first. fromJSON reads it back.
Import it
import { toJSON } from "@johnmorrisdotca/tane";
Definition
function toJSON(position: StreamPosition): string
Parameters
| Name | Type | Description |
|---|---|---|
position | StreamPosition | The stream’s seed and nonnegative count of consumed draws. |
Returns
string
A position as JSON, two spaces deep, with the format's number first. fromJSON reads it back.
Examples
import { toJSON } from "@johnmorrisdotca/tane";
const position = { seed: 42, draws: 3 };
console.log(toJSON(position));{
"format": 1,
"generator": "tane 1.3.0",
"algorithm": "mulberry32",
"seed": 42,
"draws": 3,
"state": 1199730185
}What it prints (run when this page was built)