UNPKG
random-word
Version:
latest (3.0.0)
3.0.0
2.0.0
1.0.2
1.0.1
1.0.0
0.1.0
Get a random English word
github.com/sindresorhus/random-word
sindresorhus/random-word
random-word
/
index.js
8 lines
(5 loc)
•
235 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
import
fs
from
'node:fs'
;
import
uniqueRandomArray
from
'unique-random-array'
;
import
wordListPath
from
'word-list'
;
const
randomWord =
uniqueRandomArray
(fs.
readFileSync
(wordListPath,
'utf8'
).
split
(
'\n'
));
export
default
randomWord;