Created
May 5, 2016 23:32
-
-
Save maury91/ae76811515d92b893abdc34601da5f30 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
import fs from 'fs'; | |
import readline from 'readline'; | |
const words = {}; | |
const wordReader = readline.createInterface({ | |
input: fs.createReadStream('words.italian.txt','utf8') | |
}); | |
wordReader.on('line',( word ) => { | |
if ( word.length ) { | |
if ( !words[word.length] ) { | |
words[word.length] = []; | |
} | |
words[word.length].push(word); | |
} | |
}); | |
wordReader.on('close', () => { | |
console.log('Readed all!'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment