Class: BitField

BitField

Data structure that makes it easy to interact with a bitfield.

Constructor

new BitField(bitsopt)

Parameters:
Name Type Attributes Default Description
bits BitFieldResolvable <optional>
0 Bit(s) to read from
Source:

Members

(abstract, static) FLAGS :Object

Numeric bitfield flags. Defined in extension classes
Type:
  • Object
Source:

bitfield :number

Bitfield of the packed bits
Type:
  • number
Source:

Methods

(static) resolve(bitopt) → {number}

Resolves bitfields to their numeric form.
Parameters:
Name Type Attributes Default Description
bit BitFieldResolvable <optional>
0 bit(s) to resolve
Source:
Returns:
Type
number

add(…bitsopt) → {BitField}

Adds bits to these ones.
Parameters:
Name Type Attributes Description
bits BitFieldResolvable <optional>
<repeatable>
Bits to add
Source:
Returns:
These bits or new BitField if the instance is frozen.
Type
BitField

any(bit) → {boolean}

Checks whether the bitfield has a bit, or any of multiple bits.
Parameters:
Name Type Description
bit BitFieldResolvable Bit(s) to check for
Source:
Returns:
Type
boolean

equals(bit) → {boolean}

Checks if this bitfield equals another
Parameters:
Name Type Description
bit BitFieldResolvable Bit(s) to check for
Source:
Returns:
Type
boolean

freeze() → {Readonly.<BitField>}

Freezes these bits, making them immutable.
Source:
Returns:
These bits
Type
Readonly.<BitField>

has(bit) → {boolean}

Checks whether the bitfield has a bit, or multiple bits.
Parameters:
Name Type Description
bit BitFieldResolvable Bit(s) to check for
Source:
Returns:
Type
boolean

missing(bits, …hasParams) → {Array.<string>}

Gets all given bits that are missing from the bitfield.
Parameters:
Name Type Attributes Description
bits BitFieldResolvable Bit(s) to check for
hasParams * <repeatable>
Additional parameters for the has method, if any
Source:
Returns:
Type
Array.<string>

remove(…bitsopt) → {BitField}

Removes bits from these.
Parameters:
Name Type Attributes Description
bits BitFieldResolvable <optional>
<repeatable>
Bits to remove
Source:
Returns:
These bits or new BitField if the instance is frozen.
Type
BitField

serialize(…hasParams) → {Object}

Gets an object mapping field names to a boolean indicating whether the bit is available.
Parameters:
Name Type Attributes Description
hasParams * <repeatable>
Additional parameters for the has method, if any
Source:
Returns:
Type
Object

toArray(…hasParams) → {Array.<string>}

Gets an Array of bitfield names based on the bits available.
Parameters:
Name Type Attributes Description
hasParams * <repeatable>
Additional parameters for the has method, if any
Source:
Returns:
Type
Array.<string>