throat

  • Version 6.0.1
  • Published
  • 9.16 kB
  • No dependencies
  • MIT license

Install

npm i throat
yarn add throat
pnpm add throat

Overview

Throttle the parallelism of an asynchronous (promise returning) function / functions

Index

Functions

Functions

function throat

throat: {
<TResult, TArgs extends any[]>(
size: number,
fn: (...args: TArgs) => Promise<TResult>
): (...args: TArgs) => Promise<TResult>;
<TResult, TArgs extends any[]>(
fn: (...args: TArgs) => Promise<TResult>,
size: number
): (...args: TArgs) => Promise<TResult>;
(size: number): <TResult, TArgs extends any[] = []>(
fn: (...args: TArgs) => Promise<TResult>,
...args: TArgs
) => Promise<TResult>;
};
  • Throttle the given function to only run size times in parallel. Extra calls will be queued until one of the earlier calls completes.

  • Create a throttle that only allows size calls in parallel. Extra calls will be queued until one of the earlier calls completes.

    To create an exclusive lock, just use a size of 1.

Package Files (1)

Dependencies (0)

No dependencies.

Dev Dependencies (9)

Peer Dependencies (0)

No peer dependencies.

Badge

To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/throat.

  • Markdown
    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/throat)
  • HTML
    <a href="https://www.jsdocs.io/package/throat"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>