BitField

export class BitField<Flags extends string, Type extends number | bigint = number>
export class BitField<Flags extends string, Type extends number | bigint = number>
Data structure that makes it easy to interact with a bitfield.
NameConstraintsOptionalDefaultDescription
FlagsstringNoNone
Typenumber | bigintYesnumberNone
constructor(bits?)
NameTypeOptionalDescription
bitsBitFieldResolvable<Flags, Type>YesNone
bitfield:Type
Bitfield of the packed bits
Static
Numeric bitfield flags. Defined in extension classes
[Symbol.iterator]():IterableIterator<Flags>
add(...bits):BitField<Flags, Type>
Adds bits to these ones.
Returns
These bits or new BitField if the instance is frozen.
NameTypeOptionalDescription
...bitsBitFieldResolvable<Flags, Type>[]NoBits to add
any(bit):boolean
Checks whether the bitfield has a bit, or any of multiple bits.
NameTypeOptionalDescription
bitBitFieldResolvable<Flags, Type>NoBit(s) to check for
equals(bit):boolean
Checks if this bitfield equals another
NameTypeOptionalDescription
bitBitFieldResolvable<Flags, Type>NoBit(s) to check for
freeze():Readonly<BitField<Flags, Type>>
Freezes these bits, making them immutable.
has(bit):boolean
Checks whether the bitfield has a bit, or multiple bits.
NameTypeOptionalDescription
bitBitFieldResolvable<Flags, Type>NoBit(s) to check for
missing(bits, ...hasParams):Flags[]
Gets all given bits that are missing from the bitfield.
NameTypeOptionalDescription
bitsBitFieldResolvable<Flags, Type>NoBit(s) to check for
...hasParamsreadonly unknown[]NoAdditional parameters for the has method, if any
remove(...bits):BitField<Flags, Type>
Removes bits from these.
Returns
These bits or new BitField if the instance is frozen.
NameTypeOptionalDescription
...bitsBitFieldResolvable<Flags, Type>[]NoBits to remove
Static
resolve(bit?):number | bigint
Resolves bitfields to their numeric form.
NameTypeOptionalDescription
bitBitFieldResolvable<string, number | bigint>Yesbit(s) to resolve
serialize(...hasParams):Record<Flags, boolean>
Gets an object mapping field names to a boolean indicating whether the bit is available.
NameTypeOptionalDescription
...hasParamsreadonly unknown[]NoAdditional parameters for the has method, if any
toArray(...hasParams):Flags[]
Gets an Array of bitfield names based on the bits available.
NameTypeOptionalDescription
...hasParamsreadonly unknown[]NoAdditional parameters for the has method, if any
toJSON():Type extends number ? number : string
valueOf():Type