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 · Picker element

TanePickerOptionstype

Host data, a native random stream, optional weights and a result callback.

Import it

import type { TanePickerOptions } from "@johnmorrisdotca/tane/element";

Also exported from: @johnmorrisdotca/tane/element/define

Definition

type TanePickerOptions = {
    items?: readonly string[];
    seed?: string | number;
    random?: Random;
    weights?: readonly number[];
    onPick?: (detail: TanePickDetail) => void;
};

Members

NameTypeDescription
items (optional)readonly string[] | undefined

Host items when the items attribute is absent.

seed (optional)string | number | undefined

Host seed when the seed attribute is absent; daily takes priority.

random (optional)Random | undefined

A host stream when no seed or daily attribute is supplied.

weights (optional)readonly number[] | undefined

Nonnegative weights for picking; shuffles and groups remain uniform.

onPick (optional)((detail: TanePickDetail) => void) | undefined

Called with the same index-only detail as the native event.

Examples

import type { TanePickerOptions } from "@johnmorrisdotca/tane/element";
const options: TanePickerOptions = { items: ["A", "B"], seed: 42 };
console.log(options.items?.length);
2

What it prints (run when this page was built)

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