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

CliSurroundingstype

What the command line is run in. All of it is optional.

Import it

import type { CliSurroundings } from "@johnmorrisdotca/tane";

Definition

type CliSurroundings = {
    env?: Record<string, string | undefined>;
    stdin?: string;
    colour?: boolean;
    locale?: string;
    now?: number;
    random?: () => number;
};

Members

NameTypeDescription
env (optional)Record<string, string | undefined> | undefined

The environment, for the language (LC_ALL, LC_MESSAGES, LANG) and NO_COLOR.

stdin (optional)string | undefined

Standard input, when --stdin asks for it: one item to a line.

colour (optional)boolean | undefined

Whether the output is a terminal that shows colour. NO_COLOR and --no-color still turn it off.

locale (optional)string | undefined

The system's language where the environment names none: what Intl says, on Windows.

now (optional)number | undefined

The time, in epoch milliseconds, for --today. Now, unless given.

random (optional)(() => number) | undefined

Where a seed comes from when none is given: a function like Math.random, which it is unless given.

Examples

import { mulberry32 } from "@johnmorrisdotca/tane";
import type { CliSurroundings } from "@johnmorrisdotca/tane";

const random = mulberry32(42);
const value: CliSurroundings = { env: {}, locale: "en", colour: false, now: 1791720000000, random: mulberry32(42) };
console.log(value.locale);
en

What it prints (run when this page was built)

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