Last active
June 4, 2019 00:40
-
-
Save J3698/69dd4339789fb0e053d8dc6a3ccd64f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const alph = 'abcdefghijklmnopqrstuvwxyz' | |
try { | |
var fileContents = fs.readFileSync('./dictionary.txt', 'utf8'); | |
} catch(err) { | |
throw "Dictionary file does not exist"; | |
} | |
var words = fileContents.split('\n'); | |
words = cleanWords(words); | |
var chain = createChain(words); | |
// this is exposed to people using the package | |
exports.randomWord = function(length) { | |
if (typeof length != "number") { | |
throw "randomWord expects a number" | |
} else if (length < 2) { | |
throw "length must be at least 2" | |
} | |
return randomWord(chain, length); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment