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

[SymbolInspect]: (() => string)

Type declaration

    • (): string
    • Returns string

_data: any
_length: any
_offset: any
EMPTY: BitString

Accessors

  • get length(): number
  • Returns the length of the bitstring

    Returns number

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

  • Checks for equality

    Returns

    true if the bitstrings are equal, false otherwise

    Parameters

    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

  • Get a subscring of the bitstring

    Returns

    Parameters

    • offset: number
    • length: number

    Returns BitString

  • Format to canonical string

    Returns

    formatted bits as a string

    Returns string

Generated using TypeDoc