Created
September 22, 2016 00:42
-
-
Save hackjutsu/fa7aa410a3937aeafc2719955c0290b2 to your computer and use it in GitHub Desktop.
Reading file line by line in NodeJS
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
| 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