Defined in: async-queuer.ts:164
A flexible asynchronous queue that processes tasks with configurable concurrency control.
Features:
Tasks are processed concurrently up to the configured concurrency limit. When a task completes, the next pending task is processed if below the concurrency limit.
Error Handling:
const asyncQueuer = new AsyncQueuer<string>({
concurrency: 2,
onSuccess: (result) => {
console.log(result); // 'Hello'
}
});
asyncQueuer.addItem(async () => {
return 'Hello';
});
asyncQueuer.start();
const asyncQueuer = new AsyncQueuer<string>({
concurrency: 2,
onSuccess: (result) => {
console.log(result); // 'Hello'
}
});
asyncQueuer.addItem(async () => {
return 'Hello';
});
asyncQueuer.start();
• TFn extends AsyncQueuerFn
new AsyncQueuer<TFn>(initialOptions): AsyncQueuer<TFn>
new AsyncQueuer<TFn>(initialOptions): AsyncQueuer<TFn>
Defined in: async-queuer.ts:177
AsyncQueuerOptions<TFn> = defaultOptions
AsyncQueuer<TFn>
addItem(
fn,
position,
runOnItemsChange): void
addItem(
fn,
position,
runOnItemsChange): void
Defined in: async-queuer.ts:385
Adds a task to the queuer
TFn
QueuePosition = ...
boolean = true
void
clear(): void
clear(): void
Defined in: async-queuer.ts:363
Removes all items from the queuer
void
getActiveItems(): TFn[]
getActiveItems(): TFn[]
Defined in: async-queuer.ts:505
Returns the active items
TFn[]
getAllItems(): TFn[]
getAllItems(): TFn[]
Defined in: async-queuer.ts:498
Returns a copy of all items in the queuer
TFn[]
getConcurrency(): number
getConcurrency(): number
Defined in: async-queuer.ts:217
Returns the current concurrency limit
number
getErrorCount(): number
getErrorCount(): number
Defined in: async-queuer.ts:526
Returns the number of items that have failed processing
number
getExpirationCount(): number
getExpirationCount(): number
Defined in: async-queuer.ts:561
Returns the number of items that have expired from the queuer
number
getIsEmpty(): boolean
getIsEmpty(): boolean
Defined in: async-queuer.ts:477
Returns true if the queuer is empty
boolean
getIsFull(): boolean
getIsFull(): boolean
Defined in: async-queuer.ts:484
Returns true if the queuer is full
boolean
getIsIdle(): boolean
getIsIdle(): boolean
Defined in: async-queuer.ts:554
Returns true if the queuer is running but has no items to process
boolean
getIsRunning(): boolean
getIsRunning(): boolean
Defined in: async-queuer.ts:547
Returns true if the queuer is running
boolean
getNextItem(position): undefined | TFn
getNextItem(position): undefined | TFn
Defined in: async-queuer.ts:444
Removes and returns an item from the queuer
QueuePosition = ...
undefined | TFn
getOptions(): AsyncQueuerOptions<TFn>
getOptions(): AsyncQueuerOptions<TFn>
Defined in: async-queuer.ts:203
Returns the current queuer options
AsyncQueuerOptions<TFn>
getPeek(position): undefined | TFn
getPeek(position): undefined | TFn
Defined in: async-queuer.ts:467
Returns an item without removing it
QueuePosition = 'front'
undefined | TFn
getPendingItems(): TFn[]
getPendingItems(): TFn[]
Defined in: async-queuer.ts:512
Returns the pending items
TFn[]
getRejectionCount(): number
getRejectionCount(): number
Defined in: async-queuer.ts:540
Returns the number of items that have been rejected from the queuer
number
getSettledCount(): number
getSettledCount(): number
Defined in: async-queuer.ts:533
Returns the number of items that have completed processing (success or error)
number
getSize(): number
getSize(): number
Defined in: async-queuer.ts:491
Returns the current size of the queuer
number
getSuccessCount(): number
getSuccessCount(): number
Defined in: async-queuer.ts:519
Returns the number of items that have been successfully processed
number
getWait(): number
getWait(): number
Defined in: async-queuer.ts:210
Returns the current wait time between processing items
number
reset(withInitialItems?): void
reset(withInitialItems?): void
Defined in: async-queuer.ts:371
Resets the queuer to its initial state
boolean
void
setOptions(newOptions): void
setOptions(newOptions): void
Defined in: async-queuer.ts:196
Updates the queuer options Returns the new options state
Partial<AsyncQueuerOptions<TFn>>
void
start(): Promise<void>
start(): Promise<void>
Defined in: async-queuer.ts:331
Starts the queuer and processes items
Promise<void>
stop(): void
stop(): void
Defined in: async-queuer.ts:354
Stops the queuer from processing items
void
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.