reader.js
function onDrain(value) {
      state = value
      // If value is marked as `reduced` no further reads should take place,
      // as consumer has finished consumption.
      if (isReduced(value)) return next(end)
      // If current `position` has reached or passed `finish` mark end a
      // collection.
      else if (position >= finish) return next(end, state)

      // Otherwise read another chunk from the current position & execute
      // `onChunk` handler or `onError` if fails. Note that `readChunk`
      // reads chunk and returns either number of bytes read or a promise
      // for that or an error if failed. Errors will invoke onError handler
      // causing collection error and end. `onChunk` will propagate data
      // further likely to the writer on the other end.
      when(readChunk(fd, buffer, position, size), onChunk, onError)
    }
function onDrain(value) {
      state = value
      // If value is marked as `reduced` no further reads should take place,
      // as consumer has finished consumption.
      if (isReduced(value)) return next(end)
      // If current `position` has reached or passed `finish` mark end a
      // collection.
      else if (position >= finish) return next(end, state)

      // Otherwise read another chunk from the current position & execute
      // `onChunk` handler or `onError` if fails. Note that `readChunk`
      // reads chunk and returns either number of bytes read or a promise
      // for that or an error if failed. Errors will invoke onError handler
      // causing collection error and end. `onChunk` will propagate data
      // further likely to the writer on the other end.
      when(readChunk(fd, buffer, position, size), onChunk, onError)
    }
function onDrain ( value ) { state = value // If value is marked as `reduced` no further reads should take place, // as consumer has finished consumption. if ( isReduced ( value ) ) return next ( end ) // If current `position` has reached or passed `finish` mark end a // collection. else if ( position >= finish ) return next ( end , state ) // Otherwise read another chunk from the current position & execute // `onChunk` handler or `onError` if fails. Note that `readChunk` // reads chunk and returns either number of bytes read or a promise // for that or an error if failed. Errors will invoke onError handler // causing collection error and end. `onChunk` will propagate data // further likely to the writer on the other end. when ( readChunk ( fd , buffer , position , size ) , onChunk , onError ) }
Handler is invoked whenever consumer of the collection finished consumption of the previous chunk and can accept more data. It's also passed a new state value that is being accumulated.
Handler is invoked whenever consumer of the collection finished consumption of the previous chunk and can accept more data . It s also passed a new state value that is being accumulated .