Back to Top

promise-throttle master

A library to throttle promises

PromiseThrottle(options, requestsPerSecond)

Parameters

Name Type Description
options Object

A set op options to pass to the throttle function

requestsPerSecond number

The amount of requests per second the library will limit to

Returns

Void

PromiseThrottle.add(promise, options)

Adds a promise

Parameters

Name Type Description
promise Function

A function returning the promise to be added

options Object

A set of options.

options.signal number

An AbortSignal object that can be used to abort the returned promise

options.weight number

A "weight" of each operation resolving by array of promises

Returns

Promise

A promise

PromiseThrottle.addAll(promises, options)

Adds all the promises passed as parameters

Parameters

Name Type Description
promises Function

An array of functions that return a promise

options Object

A set of options.

options.signal number

An AbortSignal object that can be used to abort the returned promise

options.weight number

A "weight" of each operation resolving by array of promises

Returns

Promise

A promise that succeeds when all the promises passed as options do

PromiseThrottle.dequeue()

Dequeues a promise

Returns

PromiseThrottle._execute() private method

Executes the promise

Returns

PromiseThrottle(options, requestsPerSecond)

Parameters

Name Type Description
options Object

A set op options to pass to the throttle function

requestsPerSecond number

The amount of requests per second the library will limit to

Returns

Void

PromiseThrottle.add(promise, options)

Adds a promise

Parameters

Name Type Description
promise Function

A function returning the promise to be added

options Object

A set of options.

options.signal number

An AbortSignal object that can be used to abort the returned promise

options.weight number

A "weight" of each operation resolving by array of promises

Returns

Promise

A promise

PromiseThrottle.addAll(promises, options)

Adds all the promises passed as parameters

Parameters

Name Type Description
promises Function

An array of functions that return a promise

options Object

A set of options.

options.signal number

An AbortSignal object that can be used to abort the returned promise

options.weight number

A "weight" of each operation resolving by array of promises

Returns

Promise

A promise that succeeds when all the promises passed as options do

PromiseThrottle.dequeue()

Dequeues a promise

Returns

PromiseThrottle._execute() private method

Executes the promise

Returns