BitField

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