An open API service indexing awesome lists of open source software.

https://github.com/belsrc/match

Match Function
https://github.com/belsrc/match

Last synced: about 2 months ago
JSON representation

Match Function

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)