Skip to content

Instantly share code, notes, and snippets.

@NoahDragon
Created March 18, 2016 15:21
Show Gist options
  • Save NoahDragon/e89f21757f66e6a320c3 to your computer and use it in GitHub Desktop.
Save NoahDragon/e89f21757f66e6a320c3 to your computer and use it in GitHub Desktop.
Nodejs read file line by line.
module.exports = {
readlines : function (filename){
var fs = require('fs');
if (fs.existsSync(filename)) {
return fs.readFileSync(filename).toString().split(/\r?\n/);
}
else {
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment