Created
September 21, 2017 16:42
-
-
Save softwarenerd/0e5a570624bb7ba8789160c96f6e049c to your computer and use it in GitHub Desktop.
Helper to read AllWords.txt and write out an array of words.
This file contains 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
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