Skip to content

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.

T

readonly T[]

The items to shuffle. Not modified; a new array is returned.

ShuffleOptions

Optional shuffle options.

T[]

A new array containing the shuffled elements of the input.