-
-
Save chrisdickinson/397767a085f8b1227340 to your computer and use it in GitHub Desktop.
This file contains 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 characters
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js | |
index a9d9fc6..81fe17b 100644 | |
--- a/lib/_stream_readable.js | |
+++ b/lib/_stream_readable.js | |
@@ -63,6 +63,7 @@ function ReadableState(options, stream) { | |
// actions that shouldn't happen until "later" should generally also | |
// not happen before the first write call. | |
this.sync = true; | |
+ this.paused = null; | |
// whenever we return null, then we set a flag to say | |
// that we're awaiting a 'readable' event emission. | |
@@ -709,6 +710,7 @@ Readable.prototype.resume = function() { | |
}; | |
function resume(stream, state) { | |
+ state.paused = false; | |
if (!state.resumeScheduled) { | |
state.resumeScheduled = true; | |
process.nextTick(function() { | |
@@ -718,6 +720,12 @@ function resume(stream, state) { | |
} | |
function resume_(stream, state) { | |
+ if(state.paused) { | |
+ state.resumeScheduled = false; | |
+ | |
+ return; | |
+ } | |
+ | |
if (!state.reading) { | |
debug('resume read 0'); | |
stream.read(0); | |
@@ -732,6 +740,7 @@ function resume_(stream, state) { | |
Readable.prototype.pause = function() { | |
debug('call pause flowing=%j', this._readableState.flowing); | |
+ this._readableState.paused = true; | |
if (false !== this._readableState.flowing) { | |
debug('pause'); | |
this._readableState.flowing = false; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment