helpers.limit - ZeMA-gGmbH/NoPE-JS GitHub Wiki

Namespace: limit

helpers.limit

Type Aliases

TLimitedOptions

TLimitedOptions: Object

The options for call

Type declaration

Name Type Description
activeTasks Set<string> An overview with active Tasks. This is relevant for multiple Funtions.
assignControlFunction (args: any[], functions: { continueTask: () => void ; pauseTask: () => void }) => any[] Helper to assign the control function, for example on an async function.
awaitingTasks Set<string> An overview with active Tasks. This is relevant for multiple Funtions.
callbackBetween? () => Promise<void> An additional function, wich can be used between the next function in is called. e.g. sleep.
emitter EventEmitter An emitter to use.
functionId string The Id to use. If not provided, an specific id is generated
getLock (functionId: string, newTaskId: string) => boolean Helper function to request a lock.
lastDone number -
loggerLevel false | LoggerLevel A logger to use.
mapping { [index: string]: (...args: any) => Promise<any>; } Mapping for the Functions.
maxParallel number Number of elements, which could be called in parallel. 0 = sequntial
minDelay number -
queue [string, string, any[]][] An queue that should be used. If not provided, a queue is used.

Functions

getLimitedOptions

getLimitedOptions(options): Partial<TLimitedOptions>

Helper to get the default options in a shared context

Parameters

Name Type Description
options Partial<TLimitedOptions> The options to enhance the defaults.

Returns

Partial<TLimitedOptions>

The options.


limitedCalls

limitedCalls<T>(func, options): (...args: any[]) => Promise<T>

Function to limit the calls based on the settings.

Type parameters

Name
T

Parameters

Name Type Description
func (...args: any[]) => Promise<T> The function to use. This should be an async function.
options Partial<TLimitedOptions> The Options.

Returns

fn

(...args): Promise<T>

Parameters
Name Type
...args any[]
Returns

Promise<T>

⚠️ **GitHub.com Fallback** ⚠️