promise-throttle-all
v1.1.1
Published
Promise.all with limited concurrency
Downloads
11,613
Maintainers
Readme
🤏 Promise Throttle All
Promise.all with limited concurrency
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.