4.0.0 • Published 8 months ago

minimal-promise-pool v4.0.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

minimal-promise-pool

Test semantic-release

A minimal library for managing the maximum number of promise instances. For example, new PromisePool(2) limits the maximum number of concurrent executions to two.

How to Use

The following example code runs only two promises at a maximum.

import { PromisePool, sleep } from 'minimal-promise-pool';

(async () => {
  const promisePool = new PromisePool(2);
  await promisePool.run(async () => {
    console.log('First task started');
    await sleep(10 * 1000);
    console.log('First task finished');
  });
  await promisePool.run(async () => {
    console.log('Second task started');
    await sleep(10 * 1000);
    console.log('Second task finished');
  });
  await promisePool.run(async () => {
    console.log('Third task started');
    await sleep(10 * 1000);
    console.log('Third task finished');
  });
})();

The result is as follows:

First task started
Second task started
# Wait for about 10 seconds
First task finished
Third task started
Second task finished
# Wait for about 10 seconds
Third task finished
4.0.0

8 months ago

3.0.3

9 months ago

3.0.2

9 months ago

3.0.1

10 months ago

2.1.9

12 months ago

3.0.0

10 months ago

2.1.12

11 months ago

2.1.13

11 months ago

2.1.10

11 months ago

2.1.11

11 months ago

2.1.8

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.1.6

1 year ago

2.1.5

1 year ago

2.1.7

1 year ago

1.2.0

2 years ago

2.1.2

1 year ago

2.1.1

1 year ago

2.1.0

1 year ago

2.0.0

1 year ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.1

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago