Skip to content

Instantly share code, notes, and snippets.

@joshuakfarrar
Last active August 29, 2015 13:57
Show Gist options
  • Save joshuakfarrar/9810679 to your computer and use it in GitHub Desktop.
Save joshuakfarrar/9810679 to your computer and use it in GitHub Desktop.
// "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