async-composer

1.0.1 • Public • Published

async-composer

a function for compose asynchronous functions or synchronous functions

example

import asyncCompose from async-composer;

const f1 = a => `f1: ${a}`;

const f2 = b => `f2: ${b}`;

const f3 = c =>
  new Promise((r, j) => {
    setTimeout(() => r(c), 2000);
  });

console.log(asyncCompose([f1, f2])("f0"));  // f2: f1: f0

asyncCompose([f1, f2, f3])("f0").then(r => console.log("f3: " + r));    // after 2s:f3: f2: f1: f0

Readme

Keywords

Package Sidebar

Install

npm i async-composer

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

2.1 kB

Total Files

4

Last publish

Collaborators

  • echo_222