promise-throttle-all
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

🤏 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.

Install

npm i promise-throttle-all

DownloadsWeekly Downloads

875

Version

1.1.1

License

MIT

Unpacked Size

44.9 kB

Total Files

22

Last publish

Collaborators

  • robinpokorny