From d8bed91dbce1df5d5a2bb9da7d9be92437a2d73c Mon Sep 17 00:00:00 2001 From: Jonas Lochmann Date: Mon, 19 Sep 2022 02:00:00 +0200 Subject: [PATCH] Use randomInt for randomWord --- src/util/random-words.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/random-words.ts b/src/util/random-words.ts index 3066268..9875bc6 100644 --- a/src/util/random-words.ts +++ b/src/util/random-words.ts @@ -15,6 +15,7 @@ * along with this program. If not, see . */ +import { randomInt } from 'crypto' import { readFileSync } from 'fs' import { range } from 'lodash' import { resolve } from 'path' @@ -24,7 +25,7 @@ const wordlist = readFileSync(resolve(__dirname, '../../other/wordlist/de.txt')) .split('\n') .filter((item) => item.trim().length > 0) -const randomWord = () => wordlist[Math.floor(Math.random() * (wordlist.length - 1))] +const randomWord = () => wordlist[randomInt(wordlist.length)] export const randomWords = (numberOfWords: number) => ( range(numberOfWords)