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

    Function getStateBranch

    • Picks the single branch a data value belongs to.

      Routes a value being stored to the one branch admitting it against every constraint, so that a caller ingesting a value against a polymorphic shape settles it on a definite branch. A value admitted by several branches is ambiguous and one admitted by none unsatisfiable; both yield nothing rather than a branch chosen by guesswork.

      Type Parameters

      • B extends Shape

        The branch type, carried through from the branches supplied

      Parameters

      • state: unknown

        The value to route

      • branches: readonly B[]

        The branches to choose among

      Returns Optional<B>

      The sole branch state belongs to, or undefined where it belongs to none or to several