parallel-executors
TypeScript icon, indicating that this package has built-in type declarations

1.0.11 • Public • Published

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

Package Sidebar

Install

npm i parallel-executors

Weekly Downloads

7

Version

1.0.11

License

MIT

Unpacked Size

12.6 kB

Total Files

11

Last publish

Collaborators

  • rockyzh