4bitlabs Low-Level Bit/Byte Utilities
    Preparing search index...

    Interface BitReader

    The interface for both MSB and LSB bit-readers. Provides a bit-level information extraction from densely-packed bitstreams. This interface provides up to a maximum of 32-bit reads at a time, the largest bitwise-safe integer size.

    interface BitReader {
        peek32(n: number): number;
        read32(n: number): number;
        skip(n: number): BitReader;
        align(): BitReader;
        isByteAligned(): boolean;
        seek(offset: number): BitReader;
    }
    Index
    • Peek at the next n bits in the bitstream. n must be ≤ 32.

      Parameters

      • n: number

      Returns number

      Error if n > 32

    • Read the next n bits from the bitstream, and then advance the bitstream by n bits. Equivalent to a BitReader.peek32 following by a BitReader.skip. n must be ≤ 32.

      Parameters

      • n: number

        The number of bits to read.

      Returns number

      Error if n > 32

    • Advance the bitstream by n bytes. n may be larger than 32 bits.

      Parameters

      • n: number

      Returns BitReader

    • Advance the bitstream until it's aligned with the next byte-boundary. If the bitstream is already at a byte-boundary, then this is a noop.

      Returns BitReader

    • Returns true if the bytestream is aligned with a byte-boundary.

      Returns boolean

    • Seek to an arbitrary byte-offset in the bitstream, from the beginning of the bitstream.

      Parameters

      • offset: number

      Returns BitReader