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);
}
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();
}
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();
}