(n, state)
| 49848 | } |
| 49849 | |
| 49850 | function howMuchToRead(n, state) { |
| 49851 | if (state.length === 0 && state.ended) |
| 49852 | return 0; |
| 49853 | |
| 49854 | if (state.objectMode) |
| 49855 | return n === 0 ? 0 : 1; |
| 49856 | |
| 49857 | if (isNaN(n) || n === null) { |
| 49858 | // only flow one buffer at a time |
| 49859 | if (state.flowing && state.buffer.length) |
| 49860 | return state.buffer[0].length; |
| 49861 | else |
| 49862 | return state.length; |
| 49863 | } |
| 49864 | |
| 49865 | if (n <= 0) |
| 49866 | return 0; |
| 49867 | |
| 49868 | // If we're asking for more than the target buffer level, |
| 49869 | // then raise the water mark. Bump up to the next highest |
| 49870 | // power of 2, to prevent increasing it excessively in tiny |
| 49871 | // amounts. |
| 49872 | if (n > state.highWaterMark) |
| 49873 | state.highWaterMark = roundUpToNextPowerOf2(n); |
| 49874 | |
| 49875 | // don't have that much. return null, unless we've ended. |
| 49876 | if (n > state.length) { |
| 49877 | if (!state.ended) { |
| 49878 | state.needReadable = true; |
| 49879 | return 0; |
| 49880 | } else |
| 49881 | return state.length; |
| 49882 | } |
| 49883 | |
| 49884 | return n; |
| 49885 | } |
| 49886 | |
| 49887 | // you can override either this method, or the async _read(n) below. |
| 49888 | Readable.prototype.read = function(n) { |
no test coverage detected