Skip to content

Instantly share code, notes, and snippets.

@maury91
Created May 5, 2016 23:32
Show Gist options
  • Save maury91/ae76811515d92b893abdc34601da5f30 to your computer and use it in GitHub Desktop.
Save maury91/ae76811515d92b893abdc34601da5f30 to your computer and use it in GitHub Desktop.
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