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

shufflefunction

The list in place, in a random order (Fisher–Yates, from the end): one draw for each item but the first. Returns the same array.

Import it

import { shuffle } from "@johnmorrisdotca/tane";

Definition

function shuffle<T>(random: Random, items: T[]): T[]

Parameters

NameTypeDescription
randomRandom

A random source returning values in [0, 1).

itemsT[]

The items to choose or shuffle; shuffle mutates this array, while shuffled copies it.

Returns

T[]

The list in place, in a random order (Fisher–Yates, from the end): one draw for each item but the first. Returns the same array.

Examples

import { mulberry32, shuffle } from "@johnmorrisdotca/tane";

const random = mulberry32(42);
console.log(shuffle(random, ["A", "B", "C"]));
[ 'C', 'A', 'B' ]

What it prints (run when this page was built)

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