Skip to content

Instantly share code, notes, and snippets.

@nickleefly
Last active December 11, 2015 11:38
Show Gist options
  • Save nickleefly/4594940 to your computer and use it in GitHub Desktop.
Save nickleefly/4594940 to your computer and use it in GitHub Desktop.
createWriteStream
var fs = require('fs');
var writeStream = fs.createWriteStream('/Users/asus/Documents/work/writeStream.txt');
var interval = setInterval(function() {
var flushed = writeStream.write((new Date()).toString() + '\n');
console.log('flushed: ', flushed);
}, 100);
setTimeout(function() {
clearInterval(interval);
writeStream.end();
},5000);
writeStream.on('drain', function() {
console.log('drained');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment