pta

promise-throttle-all

🀏 Promise.all with limited concurrency

Showing:

Popularity

Downloads/wk

29

GitHub Stars

8

Maintenance

Last Commit

2mos ago

Contributors

1

Package

Dependencies

0

License

MIT

Type Definitions

Built-In

Tree-Shakeable

Yes?

Categories

Readme

🀏 Promise Throttle All

Promise.all with limited concurrency

CI license Library minified size git3moji typescript buy-me-a-coffee

Limit in-progress async operations, like running only few API requests at a time

Quick use

import { throttleAll } from 'promise-throttle-all'

// task1 takes 100ms to complete
const task1 = () => new Promise((resolve) => {
  setTimeout(resolve, 100, 1);
});

const task2 = () => Promise.resolve(2);

// Limit concurently running promises to 1
throttleAll(1, [task1, task2])
  .then((values) => { console.log(values) });
// task2 will run after task1 finishes
// logs: `[1, 2]`

Installation

This library is published in the NPM registry and can be installed using any compatible package manager.

npm install promise-throttle-all --save

# For Yarn, use the command below.
yarn add promise-throttle-all

Installation from CDN

This module has an UMD bundle available through JSDelivr and Unpkg CDNs.

<!-- For UNPKG use the code below. -->
<script src="https://unpkg.com/promise-throttle-all"></script>

<!-- For JSDelivr use the code below. -->
<script src="https://cdn.jsdelivr.net/npm/promise-throttle-all"></script>

<script>
  // UMD module is exposed through the "promiseThrottleAll" global variable.
  console.log(promiseThrottleAll);
</script>

Documentation

Documentation generated from source files by Typedoc.

License

Released under MIT License.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100