Skip to main content
Module

x/structurae/index.ts>BitFieldStructure

Data structures for high-performance JavaScript applications.
Latest
interface BitFieldStructure
import { type BitFieldStructure } from "https://deno.land/x/structurae@4.0.1/index.ts";

Type Parameters

K extends PropertyKey
optional
N extends number | bigint = number

Methods

[[Symbol.iterator]](): Generator<number>

Iterates over numbers stored in the instance.

get(field: K): number

Returns the value of a given field.

has(...fields: Array<K>): boolean

Checks whether the instance has all the specified fields set to 1. Useful for bit flags.

match(matcher: Partial<Record<K, number>> | [N, N]): boolean

Checks if the instance contains all the key-value pairs listed in matcher. Use BigBitField.getMatcher to get an array of precomputed values that you can use to efficiently compare multiple instances to the same key-value pairs as shown in the examples below.

set(field: K, value?: number): this

Stores a given value in a field.

toJSON(): N

Returns the bigint value of an instance.

toObject(): Record<K, number>

Returns the object representation of the instance, with field names as properties with corresponding values.

toString(): string

Returns a string representing the value of the instance.

valueOf(): N

Returns the bigint value of an instance.