@metreeca/blue - v0.10.0
    Preparing search index...

    Function getStateVariant

    • Picks the single variant compatible with a state value.

      Routes a state value to the one variant that admits it against all constraints, so a caller ingesting a value against a polymorphic union can settle it on a definite branch for persistence. Because persistence must commit to a single branch, a value admitted by several variants is ambiguous and a value admitted by none is unsatisfiable; both are reported as no match rather than resolved by guessing. A state value is a resource instance on ingress, or a set-matching option within a selection.

      A relational bound is not a state value: it need not be a legal element value (a >= 8 bound over a [1, 5] domain is a legal query, not an error), so it routes by a relaxed rule keyed on syntactic traits alone under the union design's literal-disjointness rule, not through this entry point.

      Type Parameters

      • V extends ValuesShape

        The variant shape type, preserved from the input array to the returned variant

      Parameters

      • state: unknown

        The state value to route

      • variants: readonly V[]

        The union variants to choose among

      Returns V | undefined

      The sole variant the value fits, or undefined when it fits none (unsatisfiable) or several (ambiguous)