|
@ -181,20 +181,17 @@ Readable.prototype.read = function(n) { |
|
|
if (state.length - n <= state.highWaterMark) |
|
|
if (state.length - n <= state.highWaterMark) |
|
|
doRead = true; |
|
|
doRead = true; |
|
|
|
|
|
|
|
|
// if we currently have *nothing*, then always try to get *something*
|
|
|
|
|
|
// no matter what the high water mark says.
|
|
|
|
|
|
if (state.length === 0) |
|
|
|
|
|
doRead = true; |
|
|
|
|
|
|
|
|
|
|
|
// however, if we've ended, then there's no point, and if we're already
|
|
|
// however, if we've ended, then there's no point, and if we're already
|
|
|
// reading, then it's unnecessary.
|
|
|
// reading, then it's unnecessary.
|
|
|
if (state.ended || state.reading) |
|
|
if (state.ended || state.reading) |
|
|
doRead = false; |
|
|
doRead = false; |
|
|
|
|
|
|
|
|
if (doRead) { |
|
|
if (doRead) { |
|
|
var sync = true; |
|
|
|
|
|
state.reading = true; |
|
|
state.reading = true; |
|
|
state.sync = true; |
|
|
state.sync = true; |
|
|
|
|
|
// if the length is currently zero, then we *need* a readable event.
|
|
|
|
|
|
if (state.length === 0) |
|
|
|
|
|
state.needReadable = true; |
|
|
// call internal read method
|
|
|
// call internal read method
|
|
|
this._read(state.bufferSize, state.onread); |
|
|
this._read(state.bufferSize, state.onread); |
|
|
state.sync = false; |
|
|
state.sync = false; |
|
@ -219,6 +216,11 @@ Readable.prototype.read = function(n) { |
|
|
|
|
|
|
|
|
state.length -= n; |
|
|
state.length -= n; |
|
|
|
|
|
|
|
|
|
|
|
// If we have nothing in the buffer, then we want to know
|
|
|
|
|
|
// as soon as we *do* get something into the buffer.
|
|
|
|
|
|
if (state.length === 0 && !state.ended) |
|
|
|
|
|
state.needReadable = true; |
|
|
|
|
|
|
|
|
return ret; |
|
|
return ret; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -655,6 +657,9 @@ Readable.prototype.wrap = function(stream) { |
|
|
var ret = fromList(n, state.buffer, state.length, !!state.decoder); |
|
|
var ret = fromList(n, state.buffer, state.length, !!state.decoder); |
|
|
state.length -= n; |
|
|
state.length -= n; |
|
|
|
|
|
|
|
|
|
|
|
if (state.length === 0 && !state.ended) |
|
|
|
|
|
state.needReadable = true; |
|
|
|
|
|
|
|
|
if (state.length <= state.lowWaterMark && paused) { |
|
|
if (state.length <= state.lowWaterMark && paused) { |
|
|
stream.resume(); |
|
|
stream.resume(); |
|
|
paused = false; |
|
|
paused = false; |
|
|