Last active
August 29, 2015 14:22
-
-
Save rootid/0d4736fa3a4d2aae9040 to your computer and use it in GitHub Desktop.
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
//sync v/s async | |
//Count # of lines | |
var fs = require('fs') | |
var fileName = process.argv[2] | |
//Async call | |
fs.readFile(fileName,function (err, data) { | |
lst_ = data.toString(); | |
console.log(lst_.split('\n').length - 1); | |
}); | |
//Sync call | |
buffer_ = fs.readFileSync(fileName); | |
len_ = buffer_.toString().split('\n').length - 1; | |
console.log(len_) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment