Skip to content

Instantly share code, notes, and snippets.

@isaacs isaacs/gist:6359727
Last active Dec 21, 2015

Embed
What would you like to do?
$ cat p.js
var stream = require('stream');
var util = require('util');
var Peek = function () {
stream.Writable.call(this);
};
util.inherits(Peek, stream.Writable);
Peek.prototype._write = function (chunk, encoding, callback) {
callback();
};
var preview = new Peek();
preview.on('finish', function () {
console.log('finish');
});
preview.write('some text', 'utf-8', function(er) {
console.log('write cb');
});
preview.end(function() {
console.log('end cb');
});
console.log('end of tick');
$ ./node p.js
end of tick
write cb
finish
end cb
$ ../node-v0.10/node p.js
finish
end of tick
write cb
end cb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.