-
-
Save TooTallNate/7ddb4551bd941e84b104 to your computer and use it in GitHub Desktop.
readable.js: implicit _read() call when "lowWaterMark" is greater than 0
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/readable.js b/readable.js | |
index 3e9253a..b10daa8 100644 | |
--- a/readable.js | |
+++ b/readable.js | |
@@ -104,6 +104,21 @@ function Readable(options) { | |
this.readable = true; | |
Stream.apply(this); | |
+ | |
+ if (this._readableState.lowWaterMark != 0) { | |
+ // we probably need an implicit _read() call. have to nextTick it in | |
+ // case the _read function gets defined after this Readable gets returned | |
+ process.nextTick(checkRead(this)); | |
+ } | |
+} | |
+ | |
+function checkRead(readable) { | |
+ var state = readable._readableState; | |
+ return function() { | |
+ if (state.length < state.lowWaterMark) { | |
+ readable.read(0); | |
+ } | |
+ }; | |
} | |
// backwards compatibility. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment