combined-stream
Advanced tools
Comparing version 1.0.7 to 1.0.8
var util = require('util'); | ||
var Stream = require('stream').Stream; | ||
var DelayedStream = require('delayed-stream'); | ||
var defer = require('./defer.js'); | ||
@@ -17,2 +16,4 @@ module.exports = CombinedStream; | ||
this._currentStream = null; | ||
this._insideLoop = false; | ||
this._pendingNext = false; | ||
} | ||
@@ -72,2 +73,20 @@ util.inherits(CombinedStream, Stream); | ||
this._currentStream = null; | ||
if (this._insideLoop) { | ||
this._pendingNext = true; | ||
return; // defer call | ||
} | ||
this._insideLoop = true; | ||
try { | ||
do { | ||
this._pendingNext = false; | ||
this._realGetNext(); | ||
} while (this._pendingNext); | ||
} finally { | ||
this._insideLoop = false; | ||
} | ||
}; | ||
CombinedStream.prototype._realGetNext = function() { | ||
var stream = this._streams.shift(); | ||
@@ -94,3 +113,3 @@ | ||
defer(this._pipeNext.bind(this, stream)); | ||
this._pipeNext(stream); | ||
}.bind(this)); | ||
@@ -97,0 +116,0 @@ }; |
@@ -5,3 +5,3 @@ { | ||
"description": "A stream that emits multiple other streams one after another.", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"homepage": "https://github.com/felixge/node-combined-stream", | ||
@@ -8,0 +8,0 @@ "repository": { |
11514
168