Functional Matcher for JavaScript
Match-case is npm package that add functional pattern matcher.
Install
npm install match-case
Basic Usage
In case of ECMAScript6
// two function argsconst result1 = // one object arg with functionconst result2 = // equal valueconst result3 = // first match case // match after case constructionconst matcher =
In case of ECMAScript5
var match = default var result =
Practical Usage
Fizz-Buzz example in case of TypeScript(ES6)
///<reference path='./node_modules/match-case/lib/index.d.ts'/> const result = Listof<any> 0 1 "2" 3 4 num:5 7 undefined 8 "9" 10 "Hello" 11 "12" null 13 14 "World" 15 16map<number> match<number>v // prevent runtime error map<string> match<numberstring>v
More Usage
Please see API spec files.
Development
Get ready
npm install
Build
npm run build
Test
npm test
Test watch
npm run test:watch