本文へ移動

Tane種

シードで同じ数列を再現し、項目を並べ替えたり選んだり、日替わりの問題を共有したり、保存した位置から再開したりできます。

「種」は英語の seed に当たる日本語です。 名前について(英語)

目次

リファレンス · 選択ツールの要素

TanePickerOptions型

リファレンスの説明と例は英語です。見出しと目次は日本語です。

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

インポート

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

ほかのエクスポート元: @johnmorrisdotca/tane/element/define

定義

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

メンバー

名前型説明
items (省略可)readonly string[] | undefined

Host items when the items attribute is absent.

seed (省略可)string | number | undefined

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

random (省略可)Random | undefined

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

weights (省略可)readonly number[] | undefined

Nonnegative weights for picking; shuffles and groups remain uniform.

onPick (省略可)((detail: TanePickDetail) => void) | undefined

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

例

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

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/tane 1.3.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。