Skip to content

Instantly share code, notes, and snippets.

Created March 2, 2015 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save anonymous/e64ac6f54c28b29d982e to your computer and use it in GitHub Desktop.
Save anonymous/e64ac6f54c28b29d982e to your computer and use it in GitHub Desktop.
var stream = require('stream');
var timer = new stream.Readable({
read: function() {
var self = this;
console.log('called');
setTimeout(function() {
self.push('ping');
console.log('pushed');
}, 100);
}
});
timer.pipe(process.stdout);
setTimeout(function() {
timer.unpipe();
}, 500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment