Please sign in to comment.
Better stream.pipe() tracking.
This commit does three things: 1. Uses an exposed counter rather than a hidden array for tracking dest streams that may have multiple inputs. This allows for significantly faster lookups, since the counter can be checked in constant time rather than searching an array for the dest object. (A proper O(1) WeakMap would be better, but that may have to wait for Harmony.) 2. Calls the 'end' event logic when there is an 'error' event on the source object (and then throws if there are no other error listeners.) This is important, because otherwise 'error' events would lead to memory leaks. 3. Clean up the style a bit. Function Declarations are not allowed within blocks in ES strict. Prefer Function Declarations to Function Expressions, because hoisting allows for more expressive ordering of logic. Downside: It adds "_pipeCount" as part of the Stream API. It'll work fine if the member is missing, but if anyone tries to use it for some other purpose, it can mess things up.
- Loading branch information...