Change `EventEmitter` to `Stream` for ".pipe()" and other Stream goodies #5

merged 1 commit into from Jun 23, 2011


None yet
3 participants

The Stream interface has been with us since node v0.4.0 landed. It's probably time to add support for it on the Message object. Would be awesome. Thanks in advance!

aredridel merged commit ecf8922 into aredridel:master Jun 23, 2011

hamin commented Jun 23, 2011

@aredridel @TooTallNate can you guys comment what changes with this update? Why use Stream instead of EventEmitter. Trying to get myself more familiar with the internals of NodeJS. Would appreciate any feedback.


aredridel commented Jun 23, 2011

Streams are EventEmitters -- but they bring along new methods, pipe() among them. So it's all moved just one level down the prototype chain, and gets a couple things for free that way.

@hamin: The Stream class inherits from EventEmitter, so this provides all the same functionality as before. However, the Stream class also exposes pipe(), and possibly in the future other helper functions to deal with generic streams in node. You can see it's source here:

Aww you beat me @aredridel, lol

hamin commented Jun 23, 2011

ah thanks @aredridel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment