Reference · Game engine and table
shuffledfunction
A shuffled copy (Fisher–Yates); the list given is left as it was.
Import it
import { shuffled } from "@johnmorrisdotca/hitotsu";
Definition
function shuffled<T>(items: readonly T[], random: Random): T[]
Parameters
| Name | Type | Description |
|---|---|---|
items | readonly T[] | The items to shuffle, leaving the input order intact. |
random | Random | A source of numbers in [0, 1). |
Returns
T[]
A shuffled copy (Fisher–Yates); the list given is left as it was.
Examples
import { seededRandom, shuffled } from "@johnmorrisdotca/hitotsu";
console.log(shuffled(["A", "B", "C"], seededRandom(42)));[ 'C', 'A', 'B' ]What it prints (run when this page was built)