Skip to content

Latest commit

 

History

History
16 lines (12 loc) · 338 Bytes

README.md

File metadata and controls

16 lines (12 loc) · 338 Bytes

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