Last active
December 21, 2015 20:09
-
-
Save isaacs/6359727 to your computer and use it in GitHub Desktop.
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
$ 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