0.0.5 • Published 2 years ago
bootstrap-pattern-matching.macro v0.0.5
Installation
With npm:
npm install --save-dev pattern-matching.macro
Setup
.babelrc
{
"plugins": ["babel-plugin-macros"]
}
Usage
Macros
pattern-matching.macro
also ships with babel-macros supported 🎉
To use a macro you will need to
install and setup babel-macros
.
Once you have enabled babel-macros
import/require the match
macro with:
import match from 'pattern-matching.macro';
// OR
const match = require('pattern-matching.macro');
Example
import match from 'pattern-matching.macro'
const fib = n=>match(n)(
(v=1)=>1,
(v=2)=>1,
_=>fib(_-1)+fib(_-2)
)
console.log(fib(10))
// -> 55
LICENSE
MIT