Implications for EventEmitter2 and .pipe()
APIs
I have been working on refactoring node-cloudfiles to use @mikeal's request library for HTTPS uploads now that they are more stable. The current pull-request makes use of the continue
event which it seems is not handled by the default .pipe()
handler (for good reason). The work around potentially supporting this in request has made me revisit the need for EventEmitter2 with some new arguments that I find more compelling that those which were laid out before, that is: Selective Piping.
Suppose that you wish to pipe arbitrary events from one stream to another, but only those which are relevant to your concerns. For example, if you were piping an http.ClientReqest
stream to an http.ClientResponse
stream you may wish to only pipe those events relevant to the http
module (i.e. ignore those events from net.Stream
).
If we were to use EventEmitter2, we could namespace these events under http:*
and tcp:*
. Clearly to put EventEmitter2 in these hot paths the wildcard implementation would need to be optimized for namespaces of length 2-3. Very infrequently do I find myself going deeper than foo:bar:baz
.
I feel as though I'm really just scratching the surface here, and given the importance of the .pipe()
API in the current road map (to my understanding anyway), I wanted to put it out there and see what the thoughts were from everyone else.