Skip to content

Instantly share code, notes, and snippets.

@nickleefly
Last active December 11, 2015 11:38
Show Gist options
  • Save nickleefly/4594793 to your computer and use it in GitHub Desktop.
Save nickleefly/4594793 to your computer and use it in GitHub Desktop.
createReadStream
var fs = require('fs');
var readStream = fs.createReadStream('/Users/asus/Documents/work/script.js');
readStream.pause();
readStream.on('data', function(data) {
console.log('got some data:', data);
readStream.pause();
setTimeout(function() {
readStream.resume();
}, 100);
});
readStream.on('end', function() {
console.log('ended');
});
//readStream.setEncoding('base64');
setTimeout(function() {
readStream.resume();
}, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment