summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/_stream_readable.js20
-rw-r--r--lib/_stream_transform.js4
-rw-r--r--lib/_stream_writable.js10
-rw-r--r--lib/fs.js1
-rw-r--r--lib/tty.js1
-rw-r--r--lib/zlib.js19
6 files changed, 9 insertions, 46 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;
diff --git a/lib/_stream_transform.js b/lib/_stream_transform.js
index 8b75a52b62..b83fedb626 100644
--- a/lib/_stream_transform.js
+++ b/lib/_stream_transform.js
@@ -60,9 +60,7 @@
//
// However, even in such a pathological case, only a single written chunk
// would be consumed, and then the rest would wait (un-transformed) until
-// the results of the previous transformed chunk were consumed. Because
-// the transform happens on-demand, it will only transform as much as is
-// necessary to fill the readable buffer to the specified lowWaterMark.
+// the results of the previous transformed chunk were consumed.
module.exports = Transform;
diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js
index d6c84d9494..9fe4c85bd3 100644
--- a/lib/_stream_writable.js
+++ b/lib/_stream_writable.js
@@ -41,21 +41,13 @@ function WritableState(options, stream) {
var hwm = options.highWaterMark;
this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
- // the point that it has to get to before we call _write(chunk,cb)
- // default to pushing everything out as fast as possible.
- this.lowWaterMark = options.lowWaterMark || 0;
-
// object stream flag to indicate whether or not this stream
// contains buffers or objects.
this.objectMode = !!options.objectMode;
// cast to ints.
- this.lowWaterMark = ~~this.lowWaterMark;
this.highWaterMark = ~~this.highWaterMark;
- if (this.lowWaterMark > this.highWaterMark)
- throw new Error('lowWaterMark cannot be higher than highWaterMark');
-
this.needDrain = false;
// at the start of calling end()
this.ending = false;
@@ -225,7 +217,7 @@ function onwrite(stream, er) {
return;
}
- if (state.length <= state.lowWaterMark && state.needDrain) {
+ if (state.length === 0 && state.needDrain) {
// Must force callback to be called on nextTick, so that we don't
// emit 'drain' before the write() consumer gets the 'false' return
// value, and has a chance to attach a 'drain' listener.
diff --git a/lib/fs.js b/lib/fs.js
index 7209d2a304..78940a8304 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -1390,7 +1390,6 @@ function ReadStream(path, options) {
// a little bit bigger buffer and water marks by default
options = util._extend({
bufferSize: 64 * 1024,
- lowWaterMark: 16 * 1024,
highWaterMark: 64 * 1024
}, options || {});
diff --git a/lib/tty.js b/lib/tty.js
index 4ba276818d..ccc1ebee28 100644
--- a/lib/tty.js
+++ b/lib/tty.js
@@ -46,7 +46,6 @@ function ReadStream(fd, options) {
options = util._extend({
highWaterMark: 0,
- lowWaterMark: 0,
readable: true,
writable: false,
handle: new TTY(fd, true)
diff --git a/lib/zlib.js b/lib/zlib.js
index e81559dc9f..409286bc14 100644
--- a/lib/zlib.js
+++ b/lib/zlib.js
@@ -309,24 +309,7 @@ Zlib.prototype.reset = function reset() {
};
Zlib.prototype._flush = function(output, callback) {
- var rs = this._readableState;
- var self = this;
- this._transform(null, output, function(er) {
- if (er)
- return callback(er);
-
- // now a weird thing happens... it could be that you called flush
- // but everything had already actually been consumed, but it wasn't
- // enough to get over the Readable class's lowWaterMark.
- // In that case, we emit 'readable' now to make sure it's consumed.
- if (rs.length &&
- rs.length < rs.lowWaterMark &&
- !rs.ended &&
- rs.needReadable)
- self.emit('readable');
-
- callback();
- });
+ this._transform(null, output, callback);
};
Zlib.prototype.flush = function(callback) {