stream: notify user of to pipe state via 'unpipe' event. #3785

Closed
wants to merge 1 commit into
from
View
@@ -101,6 +101,8 @@ Stream.prototype.pipe = function(dest, options) {
dest.removeListener('end', cleanup);
dest.removeListener('close', cleanup);
+
+ source.emit('unpipe', dest);
}
source.on('end', cleanup);
@@ -109,7 +111,7 @@ Stream.prototype.pipe = function(dest, options) {
dest.on('end', cleanup);
dest.on('close', cleanup);
- dest.emit('pipe', source);
+ dest.emit('pipe', source, cleanup);
// Allow for unix-like usage: A.pipe(B).pipe(C)
return dest;