Skip to content

Instantly share code, notes, and snippets.

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