本文へ移動

Tane種

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

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

目次

リファレンス · 乱数列・抽選・シード

CliSurroundings型

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

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

インポート

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

定義

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

メンバー

名前型説明
env (省略可)Record<string, string | undefined> | undefined

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

stdin (省略可)string | undefined

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

colour (省略可)boolean | undefined

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

locale (省略可)string | undefined

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

now (省略可)number | undefined

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

random (省略可)(() => number) | undefined

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

例

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

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

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

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