Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/darky/ts-multimethod

TypeScript multimethods inspired by Clojure multimethods
https://github.com/darky/ts-multimethod

clojure method multimethod typescript

Last synced: 3 months ago
JSON representation

TypeScript multimethods inspired by Clojure multimethods

Awesome Lists containing this project

README

        

# ts-multimethod

TypeScript multimethods inspired by Clojure multimethods

## Example

```typescript
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
```