API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classFlags

@codexo/exojs / math / stable

Type-safe bitfield utility for managing sets of numeric enum flags. `T` should be a numeric const-enum or a type whose values are `number`. Internally stores the combined flags as a single 32-bit integer. Pass the enum TYPE as `T`, not `typeof MyEnum` - the reverse mapping of a numeric enum object carries string values and does not satisfy the constraint. Rest-argument methods (push, remove, has) allocate an array per call. On hot paths use the mask forms (addMask, removeMask, hasMask, popMask) with a pre-combined mask instead.

1
props
10
methods
0
events
Import
import { Flags } from '@codexo/exojs'

Type-safe bitfield utility for managing sets of numeric enum flags.

`T` should be a numeric const-enum or a type whose values are `number`. Internally stores the combined flags as a single 32-bit integer.

Pass the enum TYPE as `T`, not `typeof MyEnum` - the reverse mapping of a numeric enum object carries string values and does not satisfy the constraint.

Rest-argument methods (push, remove, has) allocate an array per call. On hot paths use the mask forms (addMask, removeMask, hasMask, popMask) with a pre-combined mask instead.

Constructors1
new(flags: number[]): Flags<T>
Methods10
addMask(mask: number): this
Set every bit of mask (bitwise OR). Mutates in place and returns this for chaining. Prefer this over push on hot paths: a rest parameter allocates an array on every call, and the scene graph's transform invalidation runs one of these per ancestor per mutation.
clear(): this
destroy(): void
has(flags: V[]): boolean
Return true when **any** of the supplied flags are currently set (bitwise OR test). Allocates a rest array and a closure per call - use hasMask on hot paths.
hasMask(mask: number): boolean
Return true when **any** bit of mask is currently set. Allocation-free counterpart of has.
pop(flag: V): boolean
Remove flag and return true if it was active before removal, false otherwise. Useful for one-shot consumption of a flag.
popMask(mask: number): boolean
Clear every bit of mask and return whether any of them was set before. Allocation-free counterpart of pop.
push(flags: V[]): this
Set one or more flags (bitwise OR). Mutates in place and returns this for chaining. Allocates a rest array per call - use addMask on hot paths.
remove(flags: V[]): this
Clear one or more flags (bitwise AND NOT). Mutates in place and returns this for chaining. Allocates a rest array per call - use removeMask on hot paths.
removeMask(mask: number): this
Clear every bit of mask (bitwise AND NOT). Mutates in place and returns this for chaining. Allocation-free counterpart of remove.
Properties1
value: number
Current combined bitmask of all active flags.
Source