Remove support for multi-source pipe()
authorFelix Geisendörfer <felix@debuggable.com>
Mon, 21 Nov 2011 21:57:33 +0000 (22:57 +0100)
committerisaacs <i@izs.me>
Tue, 22 Nov 2011 16:51:19 +0000 (08:51 -0800)
This reverts 6c5b31bd which had too few use cases, too much complexity,
and can be handled in user-land by using `{end: false}`.

Closes #1996

lib/stream.js
test/simple/test-stream-pipe-cleanup.js

index fa45b8b..d6da252 100644 (file)
@@ -52,12 +52,8 @@ Stream.prototype.pipe = function(dest, options) {
   dest.on('drain', ondrain);
 
   // If the 'end' option is not supplied, dest.end() will be called when
-  // source gets the 'end' or 'close' events.  Only dest.end() once, and
-  // only when all sources have ended.
+  // source gets the 'end' or 'close' events.  Only dest.end() once.
   if (!dest._isStdio && (!options || options.end !== false)) {
-    dest._pipeCount = dest._pipeCount || 0;
-    dest._pipeCount++;
-
     source.on('end', onend);
     source.on('close', onclose);
   }
@@ -67,16 +63,9 @@ Stream.prototype.pipe = function(dest, options) {
     if (didOnEnd) return;
     didOnEnd = true;
 
-    dest._pipeCount--;
-
     // remove the listeners
     cleanup();
 
-    if (dest._pipeCount > 0) {
-      // waiting for other incoming streams to end.
-      return;
-    }
-
     dest.end();
   }
 
@@ -85,16 +74,9 @@ Stream.prototype.pipe = function(dest, options) {
     if (didOnEnd) return;
     didOnEnd = true;
 
-    dest._pipeCount--;
-
     // remove the listeners
     cleanup();
 
-    if (dest._pipeCount > 0) {
-      // waiting for other incoming streams to end.
-      return;
-    }
-
     dest.destroy();
   }
 
index c2df970..aa504c4 100644 (file)
@@ -77,16 +77,6 @@ assert.equal(limit, w.endCalls);
 
 w.endCalls = 0;
 
-var r2;
-r = new Readable();
-r2 = new Readable();
-
-r.pipe(w);
-r2.pipe(w);
-r.emit('close');
-r2.emit('close');
-assert.equal(1, w.endCalls);
-
 r = new Readable();
 
 for (i = 0; i < limit; i++) {