Last active
August 29, 2015 13:59
-
-
Save tbuchok/10482143 to your computer and use it in GitHub Desktop.
readable streams are fun.
This file contains 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 Readable = require('stream').Readable | |
, util = require('util') | |
; | |
util.inherits(FakeReadable, Readable); | |
function FakeReadable(options) { | |
var self = this; | |
Readable.call(self); | |
self.push(new Buffer('data')); | |
setTimeout(function() { | |
self.push(new Buffer('moar data!')); | |
self.push(null); | |
}, 2000); | |
} | |
FakeReadable.prototype._read = function(size) { | |
process.stdout.write('\nreadable!\n'); | |
}; | |
new FakeReadable() | |
.pipe(process.stdout) | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment