This plugin is made to work with point-free (tacit) functional programming by composing functions
over piping. It is inspired by the work of babel-plugin-pipe-operator-curry,
but with a very different purpose, with focus on omitting arguments. I've overloaded the operator &
for that. You
can built more complex functions from simple ones.
import { add, multiply } from 'ramda';
const add5AndMul5 = add(5) & multiply(5);
Turn into
import { add, multiply } from 'ramda';
const add5AndMul5 = (...args) => multiply(5)(add(5)(...args));
If you want to use the original bitwise and operator, you can disable this plugin in
current scope (and it children scopes) using 'no composition'
directive.
$ npm install --save-dev babel-plugin-function-composition
.babelrc
{
"plugins": ["function-composition"]
}
$ babel --plugins function-composition script.js
require('babel-core').transform('code', {
plugins: ['function-composition']
});
MIT