Class BuildBits

Used to specify repeated placements along the X+ axis in a single build command. 101 = place 2 objects with a space between. Cannot exceed 64 bits.

Constructors

  • Parameters

    • Optionalinput: string | number | bigint

      Use to initialize the bits by entering a binary string like "11001". Left to right. Trailing zeros are ignored.

    Returns BuildBits

    SyntaxError if input string cannot be converted to a BigInt.

Accessors

  • get size(): number
  • Returns number

    Amount of all the bits.

Methods

  • Returns Iterator<boolean, any, any>

  • Clears a bit at an index (makes it 0).

    Parameters

    • index: number

    Returns this

    RangeError if the index is out of [0,63].

  • Checks whether this bits equals to another.

    Parameters

    Returns boolean

  • Checks whether there is only one bit and it is set to 1, which is likely just so that a shape can be specified in the encoded data.

    Returns boolean

  • Checks whether a bit at an index is set.

    Parameters

    • index: number

    Returns boolean

  • Checks whether no bit is set.

    Returns boolean

  • Sets a bit at an index (makes it 1).

    Parameters

    • index: number

    Returns this

    RangeError if the index is out of [0,63].

  • Returns boolean[]

    Booleans representing the set and unset bits.

  • Toggles a bit at an index.

    Parameters

    • index: number
    • Optionalforce: boolean

      If specified, it works as a shortcut for set (true) and clear (false).

    Returns this

    RangeError if the index is out of [0,63].

  • Returns string

    A string of 1's and 0's representing the set and unset bits.

  • Removes leading zero bits. (Note that trailing zeros don't work anyway)

    Returns this

    const bits = new BuildBits("10100") // 101
    bits.del(0) // 001
    bits.trimLeadZeros() // 1