Attach event listener to clone only for Stream #995

This commit is contained in:
Lovell Fuller
2017-12-12 21:53:27 +00:00
parent 0894145284
commit 9fa04a0b93
3 changed files with 26 additions and 6 deletions

View File

@@ -155,12 +155,14 @@ function clone () {
const clone = this.constructor.call();
clone.options = Object.assign({}, this.options);
// Pass 'finish' event to clone for Stream-based input
this.on('finish', function () {
// Clone inherits input data
that._flattenBufferIn();
clone.options.bufferIn = that.options.bufferIn;
clone.emit('finish');
});
if (this._isStreamInput()) {
this.on('finish', function () {
// Clone inherits input data
that._flattenBufferIn();
clone.options.bufferIn = that.options.bufferIn;
clone.emit('finish');
});
}
return clone;
}