apr-compose
v3.0.3
Published
Creates a function which is a composition of the passed asynchronous functions. Each function consumes the return value of the function that follows. Composing functions f(), g(), and h() would produce the result of f(g(h())).
Downloads
7
Maintainers
Readme
compose
Creates a function which is a composition of the passed asynchronous functions. Each function consumes the return value of the function that follows. Composing functions f(), g(), and h() would produce the result of f(g(h())).
Parameters
function
Function
Examples
import compose from 'apr-compose';
const then = (v) => new Promise((resolve) => resolve(v));
const composed = compose(
async (v) => await then(v + 1),
async (v) => await then(v + 2),
async (v) => await then(v + 3)
);
const output = await composed(1); // 7
Returns Function