The question is actually asked already by Brad, but I don't find the question really answered yet. Must readable.read()
inside a readable event handler be called repeatedly? In the current node documentation the example code read:
var readable = getReadableStreamSomehow();
readable.on('readable', function() {
var chunk;
while (null !== (chunk = readable.read())) {
console.log('got %d bytes of data', chunk.length);
}
});
readable.read()
is called repeatedly.
The document says this about readable event:
Once the internal buffer is drained, a readable event will fire again when more data is available.
It also says this about read()
:
If you do not specify a size argument, then it will return all the data in the internal buffer.
So is there any case where putting it in a while loop to repeatably call read()
necessary?