Skip to content

Commit

Permalink
fix code smell
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-van-woerkens committed Aug 25, 2023
1 parent eaafbe0 commit f63171b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/utils/get-random-entries.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as crypto from "crypto"

export default function getRandomEntries<T>(array: T[], count: number): T[] {
if (count >= array.length) {
return array
Expand All @@ -6,7 +8,7 @@ export default function getRandomEntries<T>(array: T[], count: number): T[] {
const newArray: T[] = array.slice()

for (let i = newArray.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1))
const j = Math.floor(crypto.randomInt(0, i + 1))
;[newArray[i], newArray[j]] = [newArray[j], newArray[i]]
}

Expand Down

0 comments on commit f63171b

Please sign in to comment.