Skip to content

Swizz/babel-plugin-transform-magic-currying

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-plugin-transform-magic-currying

The goal of this plugin is to provide magic auto currying for all function like Elm does.

Example

In

const add = function (a, b, c) { return a + b + c; }

const min = (a, b) => a - b;

add(1,2,3) === add(1,2)(3)
add(1,2,3) === add(1)(2,3)
add(1,2,3) === add(1)(2)(3)

min(1,2) === min(1)(2)

Out

const add = _magicCurrying(function add(a, b) {
  return a + b;
});

const min = _magicCurrying((a, b) => a - b);

add(1,2,3) === add(1,2)(3)
add(1,2,3) === add(1)(2,3)
add(1,2,3) === add(1)(2)(3)

min(1,2) === min(1)(2)

Installation (Not ready yet)

$ npm install babel-plugin-transform-magic-currying

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["transform-magic-currying"]
}

Via CLI

$ babel --plugins transform-magic-currying script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-magic-currying"]
});

About

Babel transform plugin for magic auto currying - Like Elm see :

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published