Bitfield
Bitfield
Kind: global class
- Bitfield
- new Bitfield([bit])
- instance
- .any(…bit) ⇒
boolean
- .has(…bit) ⇒
boolean
- .add(…bit) ⇒
this
- .remove(…bits) ⇒
Bitfield
- .toArray() ⇒
Array
- .toString() ⇒
string
- .serialize() ⇒
Object
- .freeze() ⇒
- .any(…bit) ⇒
- static
- .Flags :
object
- .defaultBit
- .resolve(bit) ⇒
number
|bigint
- .Flags :
new Bitfield([bit])
Constructs a new instance of the class.
Param | Type | Default | Description |
---|---|---|---|
[bit] | number | this.constructor.defaultBit | The 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.
Param | Type | Description |
---|---|---|
…bit | bigint | The 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.
Param | Type | Description |
---|---|---|
…bit | bigint | The 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.
Param | Type | Description |
---|---|---|
…bit | bigint | The 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.
Param | Type | Description |
---|---|---|
…bits | bigint | The 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
Param | Type | Description |
---|---|---|
defaultBit | bigint | The 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.
Param | Type | Description |
---|---|---|
bit | any | The bit value to resolve. |