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

https://github.com/georgeosddev/patternmatchify.js

Pattern matching like Scala in JavaScript
https://github.com/georgeosddev/patternmatchify.js

Last synced: 2 months ago
JSON representation

Pattern matching like Scala in JavaScript

Awesome Lists containing this project

README

        

Experimental
---

# PatternMatchify.js

Pattern matching like Scala with Refrect/Proxy API.

```javascript
import matchify from './patternMatchify';
import {TYPES} from './patternMatchify';

let obj = {a: 1};
let result1 = matchify(obj).a.match({
1 : (a) => { return "a is 1"},
2 : (a) => { return "a is 2"},
"Hello" : (a) => { return "a is Hello"},
[TYPES.String]: (a) => { return "a is type of String"},
[TYPES.Number]: (a) => { return "a is type of Number"},
_ : (a) => { return "Not match"}
});
console.log(result1); // a is 1
```