Skip to content

Instantly share code, notes, and snippets.

@softwarenerd
Created September 21, 2017 16:42
Show Gist options
  • Save softwarenerd/0e5a570624bb7ba8789160c96f6e049c to your computer and use it in GitHub Desktop.
Save softwarenerd/0e5a570624bb7ba8789160c96f6e049c to your computer and use it in GitHub Desktop.
Helper to read AllWords.txt and write out an array of words.
function helperWords() {
var lineReader = require('readline').createInterface({
input: require('fs').createReadStream('/Users/brian/Code/CertifiedTransfer/assets/AllWords.txt')
});
var lineNumber = 0;
lineReader.on('line', function (line) {
if (lineNumber == 0) {
console.log('const words = [')
}
const word = line.charAt(0).toUpperCase() + line.slice(1);
console.log(` '${word}',`);
lineNumber++;
});
lineReader.on('close', function (line) {
console.log('];');
console.log(`// ${lineNumber}`)
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment