MCPcopy Index your code
hub / github.com/nodejs/node / howMuchToRead

Function howMuchToRead

lib/internal/streams/readable.js:639–658  ·  view source on GitHub ↗
(n, state)

Source from the content-addressed store, hash-verified

637// This function is designed to be inlinable, so please take care when making
638// changes to the function body.
639function howMuchToRead(n, state) {
640 if (n <= 0 || (state.length === 0 && (state[kState] & kEnded) !== 0))
641 return 0;
642 if ((state[kState] & kObjectMode) !== 0)
643 return 1;
644 if (NumberIsNaN(n)) {
645 // Fast path for buffers.
646 if ((state[kState] & kDecoder) === 0 && state.length)
647 return state.buffer[state.bufferIndex].length;
648
649 // Only flow one buffer at a time.
650 if ((state[kState] & kFlowing) !== 0 && state.length)
651 return state.buffer[state.bufferIndex].length;
652
653 return state.length;
654 }
655 if (n <= state.length)
656 return n;
657 return (state[kState] & kEnded) !== 0 ? state.length : 0;
658}
659
660// You can override either this method, or the async _read(n) below.
661Readable.prototype.read = function(n) {

Callers 1

readable.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…