https://github.com/zhanba/simplematch
simple type-safe pattern match
https://github.com/zhanba/simplematch
Last synced: about 1 year ago
JSON representation
simple type-safe pattern match
- Host: GitHub
- URL: https://github.com/zhanba/simplematch
- Owner: zhanba
- Created: 2020-08-04T12:23:07.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T15:04:44.000Z (over 3 years ago)
- Last Synced: 2024-04-15T15:03:05.043Z (about 2 years ago)
- Language: TypeScript
- Size: 1.92 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# simplematch
simple pattern match for typescript
## Install
```
npm i simplematch
```
## example
```typesript
type DemoType = 'cat' | 'dog' | 'bird';
const result = match({
cat: () => 'return a string',
dog: () => 'return another string',
bird: () => 'oh',
});
const result2 = match({
cat: () => true,
dog: () => false,
bird: () => true,
});
```