We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8067300 commit 5e596a9Copy full SHA for 5e596a9
src/utils/functions/index.ts
@@ -82,7 +82,7 @@ export const getRandomSample = <Type> (population: Array<Type>, n: number) => {
82
const indexes = [] as number[]
83
const indexesObject = {} as Record<number, boolean>
84
85
- while (indexes.length < n) {
+ while (indexes.length < n && indexes.length < population.length) {
86
const random = Math.floor(Math.random() * population.length)
87
if (random in indexesObject) continue
88
indexesObject[random] = true
0 commit comments