mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2025-10-04 10:19:26 +02:00
Use randomInt for randomWord
This commit is contained in:
parent
c82d3a4657
commit
d8bed91dbc
1 changed files with 2 additions and 1 deletions
|
@ -15,6 +15,7 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { randomInt } from 'crypto'
|
||||||
import { readFileSync } from 'fs'
|
import { readFileSync } from 'fs'
|
||||||
import { range } from 'lodash'
|
import { range } from 'lodash'
|
||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
|
@ -24,7 +25,7 @@ const wordlist = readFileSync(resolve(__dirname, '../../other/wordlist/de.txt'))
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.filter((item) => item.trim().length > 0)
|
.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) => (
|
export const randomWords = (numberOfWords: number) => (
|
||||||
range(numberOfWords)
|
range(numberOfWords)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue