Last active
December 11, 2015 11:38
-
-
Save nickleefly/4594940 to your computer and use it in GitHub Desktop.
createWriteStream
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
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