Reference · Streams, draws and seeds
shuffledfunction
A shuffled copy; the list given is left alone. The same order shuffle would make.
Import it
import { shuffled } from "@johnmorrisdotca/tane";
Definition
function shuffled<T>(random: Random, items: readonly T[]): T[]
Parameters
| Name | Type | Description |
|---|---|---|
random | Random | A random source returning values in [0, 1). |
items | readonly T[] | The items to choose or shuffle; shuffle mutates this array, while shuffled copies it. |
Returns
T[]
A shuffled copy; the list given is left alone. The same order shuffle would make.
Examples
import { mulberry32, shuffled } from "@johnmorrisdotca/tane";
const random = mulberry32(42);
console.log(shuffled(random, ["A", "B", "C"]));[ 'C', 'A', 'B' ]What it prints (run when this page was built)