concurrent-promise
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

ConcurrentPromise

A ts-type friendly promise Library —— Concurrent your promise!

Install

npm install concurrent-promise

Demo

import ConcurrentPromise from "concurrent-promise";

function test() {
  return new Promise((resolve) =>
    setTimeout(() => resolve("ConcurrentPromise"), 3000)
  );
}

const cp = new ConcurrentPromise(
  test,
  (e, ret) => {
    // you will see three times three times...「ConcurrentPromise」
    console.log(ret);

    if (e) {
      cp.stop().then(() => console.log("really stopped"));
    }
  },
  3 // maxConcurrentNumber. default: 5
);

cp.start().then(() => {
  // Once stop is called, it will come here
});

A ts-type friendly promise Library —— Synchronize your promise!

Readme

Keywords

Package Sidebar

Install

npm i concurrent-promise

Weekly Downloads

2

Version

1.0.1

License

ISC

Unpacked Size

8.58 kB

Total Files

7

Last publish

Collaborators

  • aweiu