streams2: Correct drain/return logic
It was testing the length *before* adding the current chunk, which is the opposite of correct. Also, the return value was flipped.
This commit is contained in:
parent
02f017d24f
commit
06e321d0f9
@ -71,13 +71,13 @@ Writable.prototype.write = function(chunk, encoding) {
|
||||
if (typeof chunk === 'string')
|
||||
chunk = new Buffer(chunk, encoding);
|
||||
|
||||
var ret = state.length >= state.highWaterMark;
|
||||
if (ret === false)
|
||||
state.needDrain = true;
|
||||
|
||||
var l = chunk.length;
|
||||
state.length += l;
|
||||
|
||||
var ret = state.length < state.highWaterMark;
|
||||
if (ret === false)
|
||||
state.needDrain = true;
|
||||
|
||||
if (state.writing) {
|
||||
state.buffer.push(chunk);
|
||||
return ret;
|
||||
|
Loading…
x
Reference in New Issue
Block a user