0.0.3 • Published 2 years ago

pattern-matching.macro v0.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago