compose-funcs
Compose functions (i.e. f(g(x)) -> (f ∘ g)(x)). Returns a function with correct length and a descriptive name
Features
- Composes functions, duh
- Returns a function with the correct length, i.e. the same length as the rightmost function
- Returns a function with a descriptive name for easier debugging, e.g:
compose(f, g, h) -> a function named "f ∘ g ∘ h"
- Returns the identity function when given no arguments to make it extra functional
Installation
Install compose-funcs
using npm:
npm install --save compose-funcs
Usage
const compose = ; const add = a + b;const double = a * 2;const doubleAndAdd = ;// doubleAndAdd.length === 2// doubleAndAdd.name === double ∘ add; // the same as: double(add(3, 4))// (3 + 4) * 2 = 14
API
compose(...functions)
Name | Type | Description |
---|---|---|
functions | Function |
Any number of functions to compose to a new function |
Returns: Function
. The composed function.
License
MIT © Joakim Carlstein