You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
6 years ago | |
|---|---|---|
| .. | ||
| LICENSE | 6 years ago | |
| README.md | 6 years ago | |
| cumpa.js | 6 years ago | |
| index.next.js | 6 years ago | |
| package.json | 6 years ago | |
README.md
cumpa
Minimal function composition implementation
cumpáin some Italian 🇮🇹 dialects meansfellow
Usage
import compose from 'cumpa'
const add2 = x => x + 2
const multiplyBy3 = x => x * 3
const add2AndMultiplyBy3 = compose(multiplyBy3, add2)
console.log(add2AndMultiplyBy3(1)) // ((1 + 2) * 3) = 9
API
Table of Contents
composeRight
Similar to compose but performs from left-to-right function composition.
see also
Parameters
fns...[function] ) - list of unary fynctions
Returns any result of the computation
compose
Performs right-to-left function composition.
Use Array.prototype.reduce() to perform right-to-left function composition.
The last (rightmost) function can accept one or more arguments; the remaining functions must be unary.
source code
Parameters
fns...[function] ) - list of unary fynctions
Returns any result of the computation