Skip to content

Commit

Permalink
SequenceStream now only starts piping once it has been hooked up to a…
Browse files Browse the repository at this point in the history
… pipe itself
  • Loading branch information
mallocator committed May 12, 2016
1 parent d3c81f3 commit 696f10a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions SequenceStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SequenceStream extends stream.Transform {
this._enabled = false;
return this.end();
}
this._current = this._streams.shift();
this._current = new stream.Readable().wrap(this._streams.shift());
this._current.on('end', () => {
this._current = null;
this._next();
Expand All @@ -58,9 +58,18 @@ class SequenceStream extends stream.Transform {
this._streams = this._streams.concat(stream);
}
}
this._next();
return this;
}

/**
* Overrides the pipe function so that we don't wire up any chains before there's a pipe to send data to.
* @returns {Stream}
*/
pipe() {
var stream = super.pipe.apply(this, arguments);
this._next();
return stream;
}
}

module.exports = SequenceStream;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "more-streams",
"version": "0.5.6",
"version": "0.5.7",
"description": "A collection of useful stream implementations",
"license": "Apache-2.0",
"homepage": "http://github.com/mallocator/more-streams",
Expand Down

0 comments on commit 696f10a

Please sign in to comment.