Skip to content

Instantly share code, notes, and snippets.

@charliegroll
Created February 24, 2013 17:38
Show Gist options
  • Select an option

  • Save charliegroll/5024740 to your computer and use it in GitHub Desktop.

Select an option

Save charliegroll/5024740 to your computer and use it in GitHub Desktop.
For some reason, test is empty after this happens but isn't while it's being populated
var test = [];
var fs = require('fs');
var filename = '/usr/share/dict/words';
require('readline').createInterface({
input: fs.createReadStream(filename),
terminal: false
}).on('line', function(line){
test.push(line);
});
console.log(test.length);
@traviskaufman
Copy link

(see comment on FB)

var test = [];
var fs = require('fs');
var filename = '/usr/share/dict/words';
require('readline').createInterface({
    input: fs.createReadStream(filename),
    terminal: false
}).on('line', function(line){
    test.push(line);
}).on('close', function() {
    console.log(test.length);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment