Last active
April 9, 2019 03:29
-
-
Save grimen/8ac7259d0f2ed4609f9cf3a09a59d4ab to your computer and use it in GitHub Desktop.
Revisions
-
grimen revised this gist
Apr 9, 2019 . 1 changed file with 28 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,16 +4,37 @@ class CombinedStream extends stream.PassThrough { super() this._streams = streams this._transformStream = undefined this.on('pipe', this.onPipe) } onPipe (sourceStream) { sourceStream.unpipe(this) for (const stream of this._streams) { sourceStream = sourceStream.pipe(stream) } const eventTypes = [ 'data', 'end', 'close', 'drain', 'error', 'finish', 'pipe', 'unpipe', ] for (const eventType of eventTypes) { sourceStream.on(eventType, (...args) => { this.emit(eventType, ...args) }) } this._transformStream = sourceStream } pipe (destinationStream, options) { -
grimen created this gist
Apr 6, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ class CombinedStream extends stream.PassThrough { constructor (...streams) { super() this._streams = streams this.on('pipe', function (sourceStream) { sourceStream.unpipe(this) for (const stream of this._streams) { sourceStream = sourceStream.pipe(stream) } this._transformStream = sourceStream }) } pipe (destinationStream, options) { return this._transformStream.pipe(destinationStream, options) } }