Skip to content

Instantly share code, notes, and snippets.

@MelvinTo
Created July 14, 2017 09:46
Show Gist options
  • Save MelvinTo/79386f1e3850b9da28440b02c512aabf to your computer and use it in GitHub Desktop.
Save MelvinTo/79386f1e3850b9da28440b02c512aabf to your computer and use it in GitHub Desktop.
dedup words (streaming process from stdin)
var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
let hash = {};
rl.on('line', function(line){
if(hash[line]) {
// skip
} else {
hash[line] = 1;
console.log(line);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment