helpers.limit - ZeMA-gGmbH/NoPE-JS GitHub Wiki
helpers.limit
TLimitedOptions: Object
The options for call
| 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. |
getLimitedOptions(options): Partial<TLimitedOptions>
Helper to get the default options in a shared context
| Name | Type | Description |
|---|---|---|
options |
Partial<TLimitedOptions> |
The options to enhance the defaults. |
Partial<TLimitedOptions>
The options.
limitedCalls<T>(func, options): (...args: any[]) => Promise<T>
Function to limit the calls based on the settings.
| Name |
|---|
T |
| Name | Type | Description |
|---|---|---|
func |
(...args: any[]) => Promise<T> |
The function to use. This should be an async function. |
options |
Partial<TLimitedOptions> |
The Options. |
fn
(...args): Promise<T>
| Name | Type |
|---|---|
...args |
any[] |
Promise<T>