Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Bitfield

Represents a Bitfield.

Hierarchy

  • Bitfield

Index

Constructors

constructor

  • Create a Bitfield.

    Parameters

    • data: BitfieldData = 0

      Can be a Node.js Buffer, ArrayBuffer, typed array, numeric array, or a number representing the amount of bytes in the Bitfield

    • Optional opts: BitfieldOptions

      Other options

    Returns Bitfield

Properties

array

array: TypedArray

Underlying typed array. Changing this manually may break the Bitfield or cause unexpected bugs.

grow

grow: number

Value of the grow option.

Methods

clear

  • clear(): void
  • Reset all bits.

    Returns void

get

  • get(index: number): boolean
  • Check if a bit is set.

    Parameters

    • index: number

      Bit index

    Returns boolean

    True if the bit is set

set

  • set(index: number, value?: number | boolean): void
  • Set a bit.

    Parameters

    • index: number

      Bit index

    • value: number | boolean = true

      Bit value

    Returns void

toBigInt

  • toBigInt(): BigInt
  • Convert Bitfield into a BigInt.

    Returns BigInt

    Node.js BigInt

toBuffer

  • toBuffer(): Buffer
  • Convert Bitfield into a Buffer.

    Returns Buffer

    Node.js Buffer

toHex

  • toHex(): string
  • Convert Bitfield into a hexadecimal string.

    Returns string

    Hexadecimal string

toString

  • toString(): string
  • Convert Bitfield into a UTF-8 encoded string.

    Returns string

    UTF-8 encoded string

Static fromBigInt

  • Create a Bitfield from a BigInt.

    static

    Parameters

    Returns Bitfield

    Bitfield

Static fromBuffer

  • Create a Bitfield from a Buffer or ArrayBuffer.

    static

    Parameters

    • buffer: ArrayBuffer | Buffer

      Buffer

    • Optional opts: BitfieldOptions

      Bitfield options

    Returns Bitfield

    Bitfield

Static fromHex

  • Create a Bitfield from a hexadecimal string.

    static

    Parameters

    • hex: string

      Hexadecimal string

    • Optional opts: BitfieldOptions

      Bitfield options

    Returns Bitfield

    Bitfield

Static fromString

  • Create a Bitfield from a UTF-8 encoded string.

    static

    Parameters

    • string: string

      UTF-8 encoded string.

    • Optional opts: BitfieldOptions

      Bitfield options

    Returns Bitfield

    Bitfield

Generated using TypeDoc