Preview deployment

class BitField

export class BitField<Flags extends string, Type extends number | bigint = number>

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

Constructors

constructor(
bits?: BitFieldResolvable<Flags, Type>
)

Type Parameters

Flags extends string

optional
Type? extends number | bigint = number

bitfield : Type

Bitfield of the packed bits

static
Flags : EnumLike<unknown, number | bigint>

Numeric bitfield flags. Defined in extension classes

[Symbol.iterator]() : IterableIterator<Flags>

add(
...bits: BitFieldResolvable<Flags, Type>[]
) : BitField<Flags, Type>

Adds bits to these ones.

Returns: These bits or new BitField if the instance is frozen.

any(
bit: BitFieldResolvable<Flags, Type>
) : boolean

Checks whether the bitfield has a bit, or any of multiple bits.

equals(
bit: BitFieldResolvable<Flags, Type>
) : boolean

Checks if this bitfield equals another

freeze() : Readonly<BitField<Flags, Type>>

Freezes these bits, making them immutable.

has(
bit: BitFieldResolvable<Flags, Type>
) : boolean

Checks whether the bitfield has a bit, or multiple bits.

missing(
bits: BitFieldResolvable<Flags, Type>
...hasParams: readonly unknown[]
) : Flags[]

Gets all given bits that are missing from the bitfield.

remove(
...bits: BitFieldResolvable<Flags, Type>[]
) : BitField<Flags, Type>

Removes bits from these.

Returns: These bits or new BitField if the instance is frozen.

static
resolve() : number | bigint

Resolves bitfields to their numeric form.

serialize(
...hasParams: readonly unknown[]
) : Record<Flags, boolean>

Gets an object mapping field names to a boolean indicating whether the bit is available.

toArray(
...hasParams: readonly unknown[]
) : Flags[]

Gets an Array of bitfield names based on the bits available.

toJSON() : Type extends number ? number : string

valueOf() : Type