MCPcopy Index your code
hub / github.com/stemkoski/stemkoski.github.com / howMuchToRead

Function howMuchToRead

MathBox/mathbox-core.js:3165–3200  ·  view source on GitHub ↗
(n, state)

Source from the content-addressed store, hash-verified

3163}
3164
3165function howMuchToRead(n, state) {
3166 if (state.length === 0 && state.ended)
3167 return 0;
3168
3169 if (state.objectMode)
3170 return n === 0 ? 0 : 1;
3171
3172 if (isNaN(n) || n === null) {
3173 // only flow one buffer at a time
3174 if (state.flowing && state.buffer.length)
3175 return state.buffer[0].length;
3176 else
3177 return state.length;
3178 }
3179
3180 if (n <= 0)
3181 return 0;
3182
3183 // If we're asking for more than the target buffer level,
3184 // then raise the water mark. Bump up to the next highest
3185 // power of 2, to prevent increasing it excessively in tiny
3186 // amounts.
3187 if (n > state.highWaterMark)
3188 state.highWaterMark = roundUpToNextPowerOf2(n);
3189
3190 // don't have that much. return null, unless we've ended.
3191 if (n > state.length) {
3192 if (!state.ended) {
3193 state.needReadable = true;
3194 return 0;
3195 } else
3196 return state.length;
3197 }
3198
3199 return n;
3200}
3201
3202// you can override either this method, or the async _read(n) below.
3203Readable.prototype.read = function(n) {

Callers 1

mathbox-core.jsFile · 0.70

Calls 2

isNaNFunction · 0.85
roundUpToNextPowerOf2Function · 0.70

Tested by

no test coverage detected