Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

stream: Unroll the write() function in Readable.pipe

  • Loading branch information...
commit 0f22d8a96aeb660c6e4be700c0a1408a56764f8c 1 parent bda45a8
@isaacs authored
Showing with 9 additions and 11 deletions.
  1. +9 −11 lib/_stream_readable.js
View
20 lib/_stream_readable.js
@@ -466,20 +466,18 @@ function flow(src) {
var chunk;
state.awaitDrain = 0;
- function write(dest, i, list) {
- var written = dest.write(chunk);
- if (false === written) {
- state.awaitDrain++;
- }
- }
-
while (state.pipesCount &&
null !== (chunk = src.read(state.pipeChunkSize))) {
- if (state.pipesCount === 1)
- write(state.pipes, 0, null);
- else
- state.pipes.forEach(write);
+ if (state.pipesCount === 1) {
+ if (false === state.pipes.write(chunk))
+ state.awaitDrain++;
+ } else {
+ for (var i = 0; i < state.pipesCount; i++) {
+ if (false === state.pipes[i].write(chunk))
+ state.awaitDrain++;
+ }
+ }
src.emit('data', chunk);
Please sign in to comment.
Something went wrong with that request. Please try again.