babel-plugin-all-curried
This plugin transform all your functions calls into calls to curried functions. This requires functional programming knowledge and being familiar with currying, how to use it on javascript and how to curried functions works.
This plugin plays nice with sanctuary because all their functions are curried this way.
While this will work also with functions curried Ramda
style we discourage the usage of magically curried functions, and instead we recommend to use
actually (also called manually) curried functions.
Curried functions are invoked this way:
2
If you want to fully commit to curried style you may be interested on my other babel plugin, curry-all
which transforms
all your function definitions to curried functions.
Example
In
// You have a curried functionconst sum3 = a + b + c// You call them normally
Out
"use strict";// You have a curried functionconst sum3 = a + b + c// It gets transformed to a curried function invocation23
If you are using my other plugin babel-plugin-curry-all
along with this one you will have all the benefits of curried functions
without the runtime overhead of magically curried functions neither the weird-looking code required to use them:
// This will be automatically curried by `babel-plugin-curry-all`const sum3 = { return a + b + c}// This will be transformed by `babel-plugin-all-curried`
"use strict"; const sum3 = { return a + b + c}// Curried function invocation23
Installation
$ npm install babel-plugin-all-curried
Usage
.babelrc
(Recommended)
Via .babelrc
Via CLI
$ babel --plugins all-curried script.js
Via Node API
;
Dev comments
This plugin is built using livescript, so you need to
understand it if you want to contribute to the source code.
Test are also on livescript, but they are directly executed by the livescript interpreter. There is a build:test
npm command to compile them down to javascript if you need to review the generated code.