Skip to content

rockyzh/parallel-executors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ParallelExecutors

npm version TypeScript License: MIT

ParallelExecutors can run a series of tasks/promises with a concurrency limit.

Table of Contents

Installation

Install it on your project

npm install --save parallel-executors

Examples with Typescript

run all promises or async functions in an array

import ParallelExecutor from 'parallel-executors';

...

await new ParallelExecutor([...], {
  workers: 3
}).execute();

run executors for all tasks in an iterable object


function* sources(count: number) {
  for (let i = 0; i < count; i++) {
    yield i;
  }
}

await new ParallelExecutor(sources(100), {
  workers: 10,
  executor: async (item: number) => {
    console.log(item);
    await sleep(10);
  }
}).execute();

Notice

  • Any task executor rejects may cause ParallelExecutor terminate.
  • Task executor returns true value can break the ParallelExecutor process.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

ParallelExecutors can run a series of tasks/promises with a concurrency limit

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published