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
- Host: GitHub
- URL: https://github.com/georgeosddev/patternmatchify.js
- Owner: georgeOsdDev
- Created: 2015-07-08T03:56:53.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-07-08T16:02:10.000Z (almost 10 years ago)
- Last Synced: 2025-01-20T19:33:27.933Z (4 months ago)
- Language: JavaScript
- Size: 109 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
```