Skip to main content

Function: getRandomSampleFromArray()

getRandomSampleFromArray<T>(array, size): T[]

Gets a random sample of specified size from the array. If the requested size is greater than the array length, returns a shuffled clone of the original array.

Type Parameters

T

Parameters

array: T[]

The source array from which to sample.

size: number

The number of elements to sample from the array.

Returns

T[]

A new array containing the random sample.

Defined in

packages/core/src/utilities/getRandomSampleFromArray.ts:8