Babel plugin to compose functions with piping using the & operator
Switch branches/tags
Nothing to show
Clone or download
Latest commit 66bad19 Aug 10, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib Version up Jan 3, 2018
src Explicit parenthesis. Always Jan 3, 2018
test Explicit parenthesis. Always Jan 3, 2018
.babelrc Add dotfiles Aug 31, 2017
.gitignore Initial commit Aug 31, 2017
.npmignore Add dotfiles Aug 31, 2017
LICENSE Initial commit Aug 31, 2017
README.md fixed directive Aug 10, 2018
package.json Version up Jan 3, 2018
yarn.lock Commit lockfile Aug 31, 2017

README.md

babel-plugin-function-composition

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.

Examples

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));

Disabling in current scope

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.

Installation

$ npm install --save-dev babel-plugin-function-composition

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["function-composition"]
}

Via CLI

$ babel --plugins function-composition script.js

Via Node API

require('babel-core').transform('code', {
  plugins: ['function-composition']
});

License

MIT