Browse Source

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.
v0.9.4-release
isaacs 13 years ago
parent
commit
06e321d0f9
  1. 8
      lib/_stream_writable.js

8
lib/_stream_writable.js

@ -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…
Cancel
Save