https://github.com/belsrc/match
Match Function
https://github.com/belsrc/match
Last synced: about 2 months ago
JSON representation
Match Function
- Host: GitHub
- URL: https://github.com/belsrc/match
- Owner: belsrc
- License: mit
- Created: 2019-09-18T02:23:52.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-09-22T22:13:34.000Z (almost 7 years ago)
- Last Synced: 2025-01-24T23:32:40.784Z (over 1 year ago)
- Language: JavaScript
- Size: 287 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JS Match
Simple little JS match function.
# Install
```
npm i -s @belsrc/match
```
# Use
```js
const arr = [ 1, 2 ];
const hello = () => 'world';
const matchRnd = Match.create([
[ 'foo', 'bar' ],
[ hello, 'its a func' ],
[ arr, 'its an array' ],
[ '_', 'default val' ],
]);
console.log(matchRnd(hello));
// >> its a func
console.log(matchRnd(arr));
// >> its an array
console.log(matchRnd(() => 'world'));
// >> default val
```
## LICENCE
[MIT](LICENCE)