Skip to main content
Module

x/structurae/bit-field.ts>BitFieldMixin

Data structures for high-performance JavaScript applications.
Latest
function BitFieldMixin
import { BitFieldMixin } from "https://deno.land/x/structurae@4.0.1/bit-field.ts";

Creates a BitField class from with a given schema. BitField uses numbers as bitfields to store and operate on data using bitwise operations. The size of the field is limited to 31 bits, for a larger bitfields consider using BigBitField class that uses bigints instead.

Examples

const Field = BitFieldMixin({ width: 8, height: 8 }); const field = new Field({ width: 100, height: 200 }); field.get('width'); //=> 100; field.get('height'); //=> 200 field.set('width', 18); field.get('width'); //=> 18 field.toObject(); //=> { width: 18, height: 200 }

Type Parameters

T extends Record<K, number>
K extends keyof T

Parameters

schema: T

the schema

Returns

the BitFieldClass