Function reader

  • Returns an AsyncGenerator that allows reading a set number of bytes from the passed source.

    Example

    import { reader } from 'it-reader'

    const stream = reader(source)

    // read 10 bytes from the stream
    const { done, value } = await stream.next(10)

    if (done === true) {
    // stream finished
    }

    if (value != null) {
    // do something with value
    }

    Parameters

    Returns Reader