Skip to content

Instantly share code, notes, and snippets.

@hackjutsu
Created September 22, 2016 00:42
Show Gist options
  • Select an option

  • Save hackjutsu/fa7aa410a3937aeafc2719955c0290b2 to your computer and use it in GitHub Desktop.

Select an option

Save hackjutsu/fa7aa410a3937aeafc2719955c0290b2 to your computer and use it in GitHub Desktop.
Reading file line by line in NodeJS
var fs = require("fs");
// Sync
var array = fs.readFileSync(path).toString().split('\n');
// Async
fs.readFile(path, function(err, f){
var array = f.toString().split('\n');
// use the array
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment