Skip to content

Bitfield

Bitfield

Kind: global class

new Bitfield([bit])

Constructs a new instance of the class.

ParamTypeDefaultDescription
[bit]numberthis.constructor.defaultBitThe bit value to initialize the instance with.

bitfield.any(…bit) ⇒ boolean

Checks if any of the given bit(s) are set in the bitfield.

Kind: instance method of Bitfield
Returns: boolean - True if any of the given bit(s) are set, false otherwise.

ParamTypeDescription
…bitbigintThe bit(s) to check.

bitfield.has(…bit) ⇒ boolean

Checks if the given bit(s) are set in the bitfield.

Kind: instance method of Bitfield
Returns: boolean - True if the bit(s) are set, false otherwise.

ParamTypeDescription
…bitbigintThe bit(s) to check.

bitfield.add(…bit) ⇒ this

Adds one or more bit(s) to the current bitfield.

Kind: instance method of Bitfield
Returns: this - The modified instance of the class.

ParamTypeDescription
…bitbigintThe bit(s) to add.

bitfield.remove(…bits) ⇒ Bitfield

Removes one or more bits from the bitfield.

Kind: instance method of Bitfield
Returns: Bitfield - A new Bitfield object with the specified bits removed.

ParamTypeDescription
…bitsbigintThe bits to remove from the bitfield.

bitfield.toArray() ⇒ Array

Converts the flags of an object into an array of keys.

Kind: instance method of Bitfield
Returns: Array - An array of keys representing the flags that are set in the object.

bitfield.toString() ⇒ string

Returns a string representation of the bitfield.

Kind: instance method of Bitfield
Returns: string - - The string representation of the bitfield.

bitfield.serialize() ⇒ Object

Serializes the current object into a JSON object.

Kind: instance method of Bitfield
Returns: Object - - The serialized object.

bitfield.freeze() ⇒

Freezes the current object, making it immutable.

Kind: instance method of Bitfield
Returns: None

Bitfield.Flags : object

An empty object representing a set of flags for a bitfield.

Kind: static property of Bitfield

Bitfield.defaultBit

Sets the default bit value for the Bitfield class.

Kind: static property of Bitfield

ParamTypeDescription
defaultBitbigintThe default bit value to set.

Bitfield.resolve(bit) ⇒ number | bigint

Resolves a bit value based on the given input.

Kind: static method of Bitfield
Returns: number | bigint - - The resolved bit value.
Throws:

  • BitfieldInvalid - If the specified bitfield is invalid or not found.
ParamTypeDescription
bitanyThe bit value to resolve.