Typed pattern matching and algebraic data types for JavaScript and TypeScript, in Node and the browser.
import { match, P, adt } from '@ossedb/patmat';const fact = (n: number): number => match(n) .with(0, () => 1) .with(P.bind('n', P.number), ({ n }) => n * fact(n - 1)) .exhaustive(); Copy
import { match, P, adt } from '@ossedb/patmat';const fact = (n: number): number => match(n) .with(0, () => 1) .with(P.bind('n', P.number), ({ n }) => n * fact(n - 1)) .exhaustive();
Typed pattern matching and algebraic data types for JavaScript and TypeScript, in Node and the browser.
Example