Skip to content

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

Notifications You must be signed in to change notification settings

aweiu/concurrent-promise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
});

Related

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

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published