1.0.6 • Published 3 years ago

tiny-ts-matcher v1.0.6

Weekly downloads
15
License
MIT
Repository
github
Last release
3 years ago

Install

npm i tiny-ts-matcher

Usage

import { createMatcher } from "tiny-ts-matcher";

const match = createMatcher("status");

type ServerResponse =
  | { status: 500; message: string }
  | { status: 400; error: string };

const result = match<ServerResponse>()({
  500: ({ message }) => message,
  400: ({ error }) => error,
  _: () => "no match",
})({ status: 500, message: "woops" });

// result: woops
1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago