Skip to content

bitmask overview

BitMask class provides static methods to manipulate bits in a number.


Table of contents


utils

BitMask (class)

BitMask class provides static methods to manipulate bits in a number.

Signature

export declare class BitMask

full (static method)

Generates a bitmask with all bits set to 1 upto the provided bit count

Signature

static full(bits: number)

fullArray (static method)

Generates an array with elements being consecutive numbers starting from 0 up to the provided number

Signature

static fullArray(bits: number)

pack (static method)

Packs an array of bit indices into a single number

Signature

static pack(value: number[], bits: number)

unpack (static method)

Unpacks a bitmask into an array of bit indices

Signature

static unpack(mask: number, bits: number)