Created
March 18, 2016 15:21
-
-
Save NoahDragon/e89f21757f66e6a320c3 to your computer and use it in GitHub Desktop.
Nodejs read file line by line.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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