bitwise-flag - v1.1.0
    Preparing search index...

    Interface IFlagsRegistry<TFlags>

    A registry for managing bitwise flags. This class maps flag keys (strings) to unique bit positions using BigInt for scalable storage.

    interface IFlagsRegistry<TFlags extends FlagKey> {
        combine(...flagKeys: TFlags[]): IFlag<TFlags>;
        empty(): IFlag<TFlags>;
        entries(): MapIterator<[TFlags, bigint]>;
        get(flagName: TFlags): bigint | undefined;
        keys(): MapIterator<TFlags>;
        parse(value: number): IFlag<TFlags>;
        parse(value: bigint): IFlag<TFlags>;
        parse(value: string, radix?: number): IFlag<TFlags>;
        values(): MapIterator<bigint>;
    }

    Type Parameters

    Implemented by

    Index

    Methods

    • Combines multiple flag keys into a single flag instance.

      Parameters

      • ...flagKeys: TFlags[]

        The flag keys to combine.

      Returns IFlag<TFlags>

      A flag instance representing the combined flags.

    • Returns a flag instance representing no set flags (i.e., a bitmask value of 0n).

      Returns IFlag<TFlags>

      A flag instance with no flags set.

    • Returns an iterator over the [key, value] pairs in the registry.

      Returns MapIterator<[TFlags, bigint]>

      An iterator over the [key, value] pairs.

    • Retrieves the BigInt value associated with the given flag name.

      Parameters

      • flagName: TFlags

        The name of the flag to retrieve.

      Returns bigint | undefined

      The BigInt value of the flag, or undefined if not found.

    • Returns an iterator over the flag keys in the registry.

      Returns MapIterator<TFlags>

      An iterator over the flag keys.

    • Parses a number value to create a flag instance.

      Parameters

      • value: number

        The numeric value to parse.

      Returns IFlag<TFlags>

      A flag instance representing the parsed value.

      If the value is negative or contains unknown flags.

    • Parses a bigint value to create a flag instance.

      Parameters

      • value: bigint

        The BigInt value to parse.

      Returns IFlag<TFlags>

      A flag instance representing the parsed value.

      If the value is negative or contains unknown flags.

    • Parses a string value to create a flag instance.

      Parameters

      • value: string

        The string value to parse.

      • Optionalradix: number

        The radix to use when parsing the string (default is 10).

      Returns IFlag<TFlags>

      A flag instance representing the parsed value.

      If the value cannot be parsed, is negative, or contains unknown flags.

    • Returns an iterator over the flag values in the registry.

      Returns MapIterator<bigint>

      An iterator over the flag values.