(stream, state, chunk, encoding)
| 468 | } |
| 469 | |
| 470 | function readableAddChunkPushByteMode(stream, state, chunk, encoding) { |
| 471 | if (chunk === null) { |
| 472 | state[kState] &= ~kReading; |
| 473 | onEofChunk(stream, state); |
| 474 | return false; |
| 475 | } |
| 476 | |
| 477 | if (typeof chunk === 'string') { |
| 478 | encoding ||= state.defaultEncoding; |
| 479 | if (state.encoding !== encoding) { |
| 480 | chunk = Buffer.from(chunk, encoding); |
| 481 | encoding = ''; |
| 482 | } |
| 483 | } else if (chunk instanceof Buffer) { |
| 484 | encoding = ''; |
| 485 | } else if (Stream._isArrayBufferView(chunk)) { |
| 486 | chunk = Stream._uint8ArrayToBuffer(chunk); |
| 487 | encoding = ''; |
| 488 | } else if (chunk !== undefined) { |
| 489 | errorOrDestroy(stream, new ERR_INVALID_ARG_TYPE( |
| 490 | 'chunk', ['string', 'Buffer', 'TypedArray', 'DataView'], chunk)); |
| 491 | return false; |
| 492 | } |
| 493 | |
| 494 | if (!chunk || chunk.length <= 0) { |
| 495 | state[kState] &= ~kReading; |
| 496 | maybeReadMore(stream, state); |
| 497 | |
| 498 | return canPushMore(state); |
| 499 | } |
| 500 | |
| 501 | if ((state[kState] & kEnded) !== 0) { |
| 502 | errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF()); |
| 503 | return false; |
| 504 | } |
| 505 | |
| 506 | if ((state[kState] & (kDestroyed | kErrored)) !== 0) { |
| 507 | return false; |
| 508 | } |
| 509 | |
| 510 | state[kState] &= ~kReading; |
| 511 | if ((state[kState] & kDecoder) !== 0 && !encoding) { |
| 512 | chunk = state[kDecoderValue].write(chunk); |
| 513 | if (chunk.length === 0) { |
| 514 | maybeReadMore(stream, state); |
| 515 | return canPushMore(state); |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | addChunk(stream, state, chunk, false); |
| 520 | return canPushMore(state); |
| 521 | } |
| 522 | |
| 523 | function readableAddChunkPushObjectMode(stream, state, chunk, encoding) { |
| 524 | if (chunk === null) { |
no test coverage detected
searching dependent graphs…