Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kyeotic/compose-func
A dependency-free Node v0.10.x compatible right-to-left compose function
https://github.com/kyeotic/compose-func
Last synced: about 1 month ago
JSON representation
A dependency-free Node v0.10.x compatible right-to-left compose function
- Host: GitHub
- URL: https://github.com/kyeotic/compose-func
- Owner: kyeotic
- License: mit
- Created: 2016-08-16T20:06:40.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-08-16T21:06:44.000Z (over 8 years ago)
- Last Synced: 2024-11-07T04:44:50.160Z (about 2 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# compose-func
A dependency-free right-to-left compose function that will run anywherenpm has several packages for function composition, and they are all too heavy for my liking. This operation is simple; it doesn't require dependencies, and it doesn't need gulp/grunt to transpile ES6.
This package
* Has no dependencies
* Has no build step
* Is supported by all node environments ***without any polyfills***
* Has no tests (YAGNI)
* Is 12 lines of code
* Works# Usage
```javascript
var compose = require('compose-func');var add1 = (x) => x + 1,
mult2 = (x) => x * 2,
square = (x) => x * x;var compose1 = compose(add1),
compose2 = compose(mult2, add1),
compose3 = compose(square, mult2, add1);compose1(0); // 1
// === add1(0)compose2(1); // 4
// === mult2(add1(0))compose3(1); // 16
// === square(mult2(add1(0)))
```