(stream, chunk, encoding, addToFront, skipChunkCheck)
| 6328 | }; |
| 6329 | |
| 6330 | function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { |
| 6331 | var state = stream._readableState; |
| 6332 | if (chunk === null) { |
| 6333 | state.reading = false; |
| 6334 | onEofChunk(stream, state); |
| 6335 | } else { |
| 6336 | var er; |
| 6337 | if (!skipChunkCheck) er = chunkInvalid(state, chunk); |
| 6338 | if (er) { |
| 6339 | stream.emit('error', er); |
| 6340 | } else if (state.objectMode || chunk && chunk.length > 0) { |
| 6341 | if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { |
| 6342 | chunk = _uint8ArrayToBuffer(chunk); |
| 6343 | } |
| 6344 | |
| 6345 | if (addToFront) { |
| 6346 | if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); |
| 6347 | } else if (state.ended) { |
| 6348 | stream.emit('error', new Error('stream.push() after EOF')); |
| 6349 | } else { |
| 6350 | state.reading = false; |
| 6351 | if (state.decoder && !encoding) { |
| 6352 | chunk = state.decoder.write(chunk); |
| 6353 | if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); |
| 6354 | } else { |
| 6355 | addChunk(stream, state, chunk, false); |
| 6356 | } |
| 6357 | } |
| 6358 | } else if (!addToFront) { |
| 6359 | state.reading = false; |
| 6360 | } |
| 6361 | } |
| 6362 | |
| 6363 | return needMoreData(state); |
| 6364 | } |
| 6365 | |
| 6366 | function addChunk(stream, state, chunk, addToFront) { |
| 6367 | if (state.flowing && state.length === 0 && !state.sync) { |
no test coverage detected
searching dependent graphs…