Skip to content

Instantly share code, notes, and snippets.

@jakefolio
Forked from chartjes/gist:4081814
Created November 15, 2012 22:59
Show Gist options
  • Save jakefolio/4082134 to your computer and use it in GitHub Desktop.
Save jakefolio/4082134 to your computer and use it in GitHub Desktop.
var fs = require('fs');
var stream = fs.createReadStream('./test/fixtures/current');
var currentData = '';
stream.on('error', function (err) {
throw err;
});
stream.on('data', function (data) {
currentData += data;
});
stream.on('end', function (data) {
// Here you can tell it to process content or pass to func: doSomethingWith(currentData);
console.log("File Contents: " + currentData);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment