Open Mertz22 opened 2 years ago
Here is a simple function to achieve this (in wordlists/lang-x.ts) :
wordlists/lang-x.ts
generateWords(amount: number): string { loadWords(this); return Array(amount) .fill(null) .reduce((acc: number[], _) => { const getRandom = () => Math.floor(Math.random() * wordlist.length); let random = getRandom(); while (acc.indexOf(random) !== -1) { random = getRandom(); } return [...acc, random]; }, []) .map(index => wordlist[index]) .join(' '); }
Originally posted by @GrandSchtroumpf in https://github.com/ethers-io/ethers.js/issues/324#issuecomment-432965927
Here is a simple function to achieve this (in
wordlists/lang-x.ts
) :Originally posted by @GrandSchtroumpf in https://github.com/ethers-io/ethers.js/issues/324#issuecomment-432965927