compose-then

1.0.1 • Public • Published

compose-then

A better implementation of the "compose" FP function that allows for composing both synchronous and asynchronous functions.

Installation:

yarn add compose-then

or

npm install --save compose-then

Example:

import compose from 'compose-then';
 
const double = x => x * 2;
const square = x => x * x;
const plus3 = x => new Promise(resolve => setTimeout(() => resolve(+ 3), 100));
 
compose(double, square, plus3)(2)
  .then(result => // Result equals 50)
  .catch(console.error);
 

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    235
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    235
  • 1.0.0
    0

Package Sidebar

Install

npm i compose-then

Weekly Downloads

184

Version

1.0.1

License

ISC

Last publish

Collaborators

  • jperasmus