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

    Function resolveMask

    • Resolves flag names to their bit values and combines them into a single mask via bitwise OR.

      Order and duplicates do not affect the result — OR is commutative, associative, and idempotent. Returns combinator.zero for an empty array. Delegates the actual fold to computeMask.

      Type Parameters

      • TFlags extends string

        The union of registered flag names.

      • TBit extends Bit

        The numeric type of the bit values (number or bigint).

      • TBrand extends string | symbol

        The registry's brand, used to keep flags from different registries structurally distinct.

      Parameters

      • registry: FlagRegistry<TFlags, TBit, TBrand>

        Supplies the repository used to resolve each name to its bit value and the combinator used to fold them.

      • names: readonly TFlags[]

        The flag names to combine.

      Returns TBit

      The bitwise OR of the bit values for all given names.

      UnknownFlagError if any name in names is not registered.

      computeMaskFromNames(registry, ["READ", "WRITE"]); // READ | WRITE
      computeMaskFromNames(registry, []); // registry.combinator.zero