matchigo - v1.0.2
    Preparing search index...

    Function matchWalk

    • Cold-path companion to match. Walks the pattern tree on every call with zero closure allocation. Slower than compile() on a hot path, faster when rules genuinely change per call (user input, per-request config, one-off factory matches). If you can hoist, prefer match()/matcher().

      Type Parameters

      • T
      • R

      Parameters

      • value: T
      • rules: readonly Rule<T, R>[]

      Returns R

      import { P, matchWalk } from "matchigo";

      function classify(value: unknown, thresholds: { hi: number; lo: number }) {
      return matchWalk<unknown, string>(value, [
      { with: P.when((n: number) => n > thresholds.hi), then: () => "hi" },
      { with: P.when((n: number) => n < thresholds.lo), then: () => "lo" },
      { otherwise: () => "mid" },
      ]);
      }