Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/haskellcamargo/babel-plugin-function-composition
Babel plugin to compose functions with piping using the & operator
https://github.com/haskellcamargo/babel-plugin-function-composition
Last synced: 1 day ago
JSON representation
Babel plugin to compose functions with piping using the & operator
- Host: GitHub
- URL: https://github.com/haskellcamargo/babel-plugin-function-composition
- Owner: haskellcamargo
- License: mit
- Created: 2017-08-31T04:57:59.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-10T11:44:53.000Z (about 6 years ago)
- Last Synced: 2024-04-25T13:01:27.710Z (7 months ago)
- Language: JavaScript
- Size: 28.3 KB
- Stars: 62
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-babel - function-composition - Function piping and composition via `&` operator, for example, `toUpper & console.log`. (Plugins / Syntax Sugar)
README
# 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](https://github.com/Swizz/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
```javascript
import { add, multiply } from 'ramda';const add5AndMul5 = add(5) & multiply(5);
```Turn into
```javascript
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
```sh
$ npm install --save-dev babel-plugin-function-composition
```## Usage
### Via `.babelrc` (Recommended)
**.babelrc**
```json
{
"plugins": ["function-composition"]
}
```### Via CLI
```sh
$ babel --plugins function-composition script.js
```### Via Node API
```javascript
require('babel-core').transform('code', {
plugins: ['function-composition']
});
```# License
MIT