ts-multimethod
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

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

Package Sidebar

Install

npm i ts-multimethod

Weekly Downloads

1

Version

0.2.0

License

MIT

Unpacked Size

6.43 kB

Total Files

5

Last publish

Collaborators

  • darrrk