shuffle
shuffle<
T>(items,options?):T[]
Defined in: sample/shuffle.ts:34
Shuffles items using the Fisher-Yates algorithm and returns a new shuffled
array.
Time complexity: O(n), one swap per element. Takes an array rather than an
Iterable because the swap step indexes freely, so a stream would have to be
materialized anyway.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”readonly T[]
The items to shuffle. Not modified; a new array is returned.
options?
Section titled “options?”Optional shuffle options.
Returns
Section titled “Returns”T[]
A new array containing the shuffled elements of the input.