zhanba / simplematch

simple type-safe pattern match

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

simplematch

simple pattern match for typescript

Install

npm i simplematch

example

type DemoType = 'cat' | 'dog' | 'bird';

const result = match<DemoType, string>({
  cat: () => 'return a string',
  dog: () => 'return another string',
  bird: () => 'oh',
});

const result2 = match<DemoType, boolean>({
  cat: () => true,
  dog: () => false,
  bird: () => true,
});

About

simple type-safe pattern match


Languages

Language:TypeScript 61.2%Language:JavaScript 38.8%