(stream, state, chunk, addToFront)
| 555 | } |
| 556 | |
| 557 | function addChunk(stream, state, chunk, addToFront) { |
| 558 | if ((state[kState] & (kFlowing | kSync | kDataListening)) === (kFlowing | kDataListening) && state.length === 0) { |
| 559 | // Use the guard to avoid creating `Set()` repeatedly |
| 560 | // when we have multiple pipes. |
| 561 | if ((state[kState] & kMultiAwaitDrain) !== 0) { |
| 562 | state.awaitDrainWriters.clear(); |
| 563 | } else { |
| 564 | state.awaitDrainWriters = null; |
| 565 | } |
| 566 | |
| 567 | state[kState] |= kDataEmitted; |
| 568 | stream.emit('data', chunk); |
| 569 | } else { |
| 570 | // Update the buffer info. |
| 571 | state.length += (state[kState] & kObjectMode) !== 0 ? 1 : chunk.length; |
| 572 | if (addToFront) { |
| 573 | if (state.bufferIndex > 0) { |
| 574 | state.buffer[--state.bufferIndex] = chunk; |
| 575 | } else { |
| 576 | state.buffer.unshift(chunk); // Slow path |
| 577 | } |
| 578 | } else { |
| 579 | state.buffer.push(chunk); |
| 580 | } |
| 581 | |
| 582 | if ((state[kState] & kNeedReadable) !== 0) |
| 583 | emitReadable(stream); |
| 584 | } |
| 585 | maybeReadMore(stream, state); |
| 586 | } |
| 587 | |
| 588 | Readable.prototype.isPaused = function() { |
| 589 | const state = this._readableState; |
no test coverage detected
searching dependent graphs…