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()

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>

Adds bits to these ones.

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

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

Checks if this bitfield equals another

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

Freezes these bits, making them immutable.

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

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

Gets all given bits that are missing from the bitfield.

remove() : 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