Awesome
ts-multimethod
TypeScript multimethods inspired by Clojure multimethods
Example
const fn = multimethod(
(n: number) => n, // <- here predicate function
() => "notZeroOrOne", // <- here default function
[0, () => "zero"], // <- further tuples like [predicate, function]
[1, () => "one"]
);
fn(0) // zero