diff options
Diffstat (limited to 'lib/_stream_readable.js')
-rw-r--r-- | lib/_stream_readable.js | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index 333a3a015d..947a0b9c9a 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -39,18 +39,10 @@ function ReadableState(options, stream) { var hwm = options.highWaterMark; this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024; - // the minimum number of bytes to buffer before emitting 'readable' - // default to pushing everything out as fast as possible. - this.lowWaterMark = options.lowWaterMark || 0; - // cast to ints. this.bufferSize = ~~this.bufferSize; - this.lowWaterMark = ~~this.lowWaterMark; this.highWaterMark = ~~this.highWaterMark; - if (this.lowWaterMark > this.highWaterMark) - throw new Error('lowWaterMark cannot be higher than highWaterMark'); - this.buffer = []; this.length = 0; this.pipes = null; @@ -111,15 +103,15 @@ Readable.prototype.push = function(chunk) { rs.onread(null, chunk); // if it's past the high water mark, we can push in some more. - // Also, if it's still within the lowWaterMark, we can stand some - // more bytes. This is to work around cases where hwm=0 and - // lwm=0, such as the repl. Also, if the push() triggered a + // Also, if we have no data yet, we can stand some + // more bytes. This is to work around cases where hwm=0, + // such as the repl. Also, if the push() triggered a // readable event, and the user called read(largeNumber) such that // needReadable was set, then we ought to push more, so that another // 'readable' event will be triggered. return rs.needReadable || rs.length < rs.highWaterMark || - rs.length <= rs.lowWaterMark; + rs.length === 0; }; // backwards compatibility. @@ -324,12 +316,12 @@ function onread(stream, er, chunk) { state.length += state.objectMode ? 1 : chunk.length; state.buffer.push(chunk); - // if we haven't gotten enough to pass the lowWaterMark, + // if we haven't gotten any data, // and we haven't ended, then don't bother telling the user // that it's time to read more data. Otherwise, emitting 'readable' // probably will trigger another stream.read(), which can trigger // another _read(n,cb) before this one returns! - if (state.length <= state.lowWaterMark) { + if (state.length === 0) { state.reading = true; stream._read(state.bufferSize, state.onread); return; |