a bit reader that reads bits from a byte-aligned stream

Implements

Constructors

Accessors

Methods

  • read a number of bits from the stream, and return them as a number

    Parameters

    • size: number

    Returns number

  • read a number of bits from the stream, and return them as a bigint

    Parameters

    • size: number

    Returns bigint

  • Read the specified number of bytes from the source and return them as a Uint8Array.

    The returned Uint8Array:

    • may be a view into a larger buffer
    • is only valid until the next call to readSync
    • may be smaller than the requested number of bytes if the end of the source is reached.

    these constraints allow for more efficient zero-copy implementations in many cases

    Parameters

    • bytes: number

      The number of bytes to read

    Returns Uint8Array

    Uint8Array containing the bytes that were read.