Class BitString

BitString is a class that represents a bitstring in a buffer with a specified offset and length

Hierarchy

  • BitString

Constructors

  • Constructing BitString from a buffer

    Parameters

    • data: Buffer

      data that contains the bitstring data. NOTE: We are expecting this buffer to be NOT modified

    • offset: number

      offset in bits from the start of the buffer

    • length: number

      length of the bitstring in bits

    Returns BitString

Properties

_data: Buffer
_length: number
_offset: number
EMPTY: BitString = ...

Accessors

Methods

  • Returns the bit at the specified index

    Throws

    Error if index is out of bounds

    Returns

    true if the bit is set, false otherwise

    Parameters

    • index: number

      index of the bit

    Returns boolean

  • Try to get a buffer from the bitstring without allocations

    Returns

    buffer if the bitstring is aligned to bytes, null otherwise

    Parameters

    • offset: number

      offset in bits

    • length: number

      length in bits

    Returns null | Buffer

  • Format to canonical string

    Returns

    formatted bits as a string

    Returns string

  • Checks if supplied object is BitString

    Returns

    true if object is BitString and false otherwise

    Parameters

    • src: unknown

      is unknow object

    Returns src is BitString

Generated using TypeDoc