stream: Pipe data in chunks matching read data

This creates better flow for large values of lowWaterMark.
pull/24504/head
Gil Pedersen 2013-02-14 20:26:54 +01:00 committed by isaacs
parent 8476aefc8e
commit 0a9930a230
1 changed files with 7 additions and 2 deletions

View File

@ -137,8 +137,13 @@ function howMuchToRead(n, state) {
if (state.objectMode)
return n === 0 ? 0 : 1;
if (isNaN(n) || n === null)
return state.length;
if (isNaN(n) || n === null) {
// only flow one buffer at a time
if (state.flowing && state.buffer.length)
return state.buffer[0].length;
else
return state.length;
}
if (n <= 0)
return 0;