Defined in: async-queuer.ts:95
A flexible asynchronous queuer 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.
const queuer = new AsyncQueuer<string>({ concurrency: 2 });
queuer.addItem(async () => {
return 'Hello';
});
queuer.start();
queuer.onSuccess((result) => {
console.log(result); // 'Hello'
});
const queuer = new AsyncQueuer<string>({ concurrency: 2 });
queuer.addItem(async () => {
return 'Hello';
});
queuer.start();
queuer.onSuccess((result) => {
console.log(result); // 'Hello'
});
• TValue
new AsyncQueuer<TValue>(initialOptions): AsyncQueuer<TValue>
new AsyncQueuer<TValue>(initialOptions): AsyncQueuer<TValue>
Defined in: async-queuer.ts:106
AsyncQueuerOptions<TValue> = defaultOptions
AsyncQueuer<TValue>
protected options: Required<AsyncQueuerOptions<TValue>>;
protected options: Required<AsyncQueuerOptions<TValue>>;
Defined in: async-queuer.ts:96
addItem(
fn,
position,
runOnUpdate): Promise<TValue>
addItem(
fn,
position,
runOnUpdate): Promise<TValue>
Defined in: async-queuer.ts:184
Adds a task to the queuer
() => Promise<TValue> & object
QueuePosition = ...
boolean = true
Promise<TValue>
clear(): void
clear(): void
Defined in: async-queuer.ts:305
Removes all items from the queuer
void
getActiveItems(): () => Promise<TValue>[]
getActiveItems(): () => Promise<TValue>[]
Defined in: async-queuer.ts:339
Returns the active items
() => Promise<TValue>[]
getAllItems(): () => Promise<TValue>[]
getAllItems(): () => Promise<TValue>[]
Defined in: async-queuer.ts:325
Returns a copy of all items in the queuer
() => Promise<TValue>[]
getExecutionCount(): number
getExecutionCount(): number
Defined in: async-queuer.ts:332
Returns the number of items that have been removed from the queuer
number
getNextItem(position): undefined | () => Promise<TValue>
getNextItem(position): undefined | () => Promise<TValue>
Defined in: async-queuer.ts:252
Removes and returns an item from the queuer
QueuePosition = ...
undefined | () => Promise<TValue>
getPendingItems(): () => Promise<TValue>[]
getPendingItems(): () => Promise<TValue>[]
Defined in: async-queuer.ts:346
Returns the pending items
() => Promise<TValue>[]
isEmpty(): boolean
isEmpty(): boolean
Defined in: async-queuer.ts:284
Returns true if the queuer is empty
boolean
isFull(): boolean
isFull(): boolean
Defined in: async-queuer.ts:291
Returns true if the queuer is full
boolean
isIdle(): boolean
isIdle(): boolean
Defined in: async-queuer.ts:422
Returns true if the queuer is running but has no items to process
boolean
isRunning(): boolean
isRunning(): boolean
Defined in: async-queuer.ts:415
Returns true if the queuer is running
boolean
onError(cb): () => void
onError(cb): () => void
Defined in: async-queuer.ts:363
Adds a callback to be called when a task errors
(error) => void
Function
void
onSettled(cb): () => void
onSettled(cb): () => void
Defined in: async-queuer.ts:373
Adds a callback to be called when a task is settled
(result) => void
Function
void
onSuccess(cb): () => void
onSuccess(cb): () => void
Defined in: async-queuer.ts:353
Adds a callback to be called when a task succeeds
(result) => void
Function
void
peek(position): undefined | () => Promise<TValue>
peek(position): undefined | () => Promise<TValue>
Defined in: async-queuer.ts:274
Returns an item without removing it
QueuePosition = 'front'
undefined | () => Promise<TValue>
reset(withInitialItems?): void
reset(withInitialItems?): void
Defined in: async-queuer.ts:313
Resets the queuer to its initial state
boolean
void
setOptions(newOptions): AsyncQueuerOptions<TValue>
setOptions(newOptions): AsyncQueuerOptions<TValue>
Defined in: async-queuer.ts:121
Updates the queuer options Returns the new options state
Partial<AsyncQueuerOptions<TValue>>
AsyncQueuerOptions<TValue>
size(): number
size(): number
Defined in: async-queuer.ts:298
Returns the current size of the queuer
number
start(): Promise<void>
start(): Promise<void>
Defined in: async-queuer.ts:383
Starts the queuer and processes items
Promise<void>
stop(): void
stop(): void
Defined in: async-queuer.ts:406
Stops the queuer from processing items
void
protected tick(): void
protected tick(): void
Defined in: async-queuer.ts:131
Processes items in the queuer
void
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.