Last active
August 29, 2015 13:57
-
-
Save joshuakfarrar/9810679 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
// "Extra bonus points if you avoid using fs.readFileSync" doesn't add value. Of course we should do it async | |
"use strict"; | |
var fs = require('fs') | |
, bt = require('buffertools'); | |
fs.readFile(process.argv[2], function(err, data) { | |
var offset = 0; | |
while (true) { | |
var nl = bt.indexOf(data, '\n', offset); | |
if (nl === -1) break; | |
console.log(data.slice(offset, nl)); | |
offset = ++nl; | |
} | |
console.log(data.slice(offset)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment