1.0.11 • Published 3 years ago

parallel-executors v1.0.11

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

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