@metreeca/core - v0.9.11
    Preparing search index...

    Interface Status<C>

    Pattern matcher.

    Accepts handlers for each condition and returns the result from the matched handler. Three usage patterns are supported:

    • All conditions handled: provide a handler for every condition, returns R
    • Some conditions with fallback: provide handlers for some conditions plus a fallback, returns R
    • Some conditions without fallback: provide handlers for some conditions only, returns R | undefined

    Type Parameters

    • C extends Conditions

      The conditions type defining all possible condition variants

    • Handles all conditions with complete handlers.

      Type Parameters

      • R

        The return type of all handlers

      Parameters

      • handlers: Handlers<C, R>

        Mapping of all condition keys to their handlers

      Returns R

      The result from the matched handler

    • Handles some conditions without a fallback.

      Type Parameters

      • R

        The return type of all handlers

      Parameters

      • handlers: Partial<Handlers<C, R>>

        Partial mapping of condition keys to handlers

      Returns R | undefined

      The result from the matched handler, or undefined if no handler matched

    • Handles some conditions with a fallback handler for unmatched conditions.

      Type Parameters

      • R

        The return type of all handlers

      Parameters

      • handlers: Partial<Handlers<C, R>>

        Partial mapping of condition keys to handlers

      • fallback: Handler<C[keyof C], R>

        Fallback handler receiving union of condition values

      Returns R

      The result from the matched handler or fallback