Framework
Version
Debouncer API Reference
Throttler API Reference
Rate Limiter API Reference
Queue API Reference

AsyncQueuerOptions

Interface: AsyncQueuerOptions<TFn>

Defined in: async-queuer.ts:7

Type Parameters

TFn extends AsyncQueuerFn

Properties

addItemsTo?

ts
optional addItemsTo: QueuePosition;
optional addItemsTo: QueuePosition;

Defined in: async-queuer.ts:12

Default position to add items to the queuer

Default

ts
'back'
'back'

concurrency?

ts
optional concurrency: number | (queuer) => number;
optional concurrency: number | (queuer) => number;

Defined in: async-queuer.ts:18

Maximum number of concurrent tasks to process. Can be a number or a function that returns a number.

Default

ts
1
1

expirationDuration?

ts
optional expirationDuration: number;
optional expirationDuration: number;

Defined in: async-queuer.ts:23

Maximum time in milliseconds that an item can stay in the queue If not provided, items will never expire


getIsExpired()?

ts
optional getIsExpired: (item, addedAt) => boolean;
optional getIsExpired: (item, addedAt) => boolean;

Defined in: async-queuer.ts:28

Function to determine if an item has expired If provided, this overrides the expirationDuration behavior

Parameters

item

TFn

addedAt

number

Returns

boolean


getItemsFrom?

ts
optional getItemsFrom: QueuePosition;
optional getItemsFrom: QueuePosition;

Defined in: async-queuer.ts:33

Default position to get items from during processing

Default

ts
'front'
'front'

getPriority()?

ts
optional getPriority: (item) => number;
optional getPriority: (item) => number;

Defined in: async-queuer.ts:39

Function to determine priority of items in the queuer Higher priority items will be processed first If not provided, will use static priority values attached to tasks

Parameters

item

TFn

Returns

number


initialItems?

ts
optional initialItems: TFn & object[];
optional initialItems: TFn & object[];

Defined in: async-queuer.ts:43

Initial items to populate the queuer with


maxSize?

ts
optional maxSize: number;
optional maxSize: number;

Defined in: async-queuer.ts:47

Maximum number of items allowed in the queuer


onError()?

ts
optional onError: (error, queuer) => void;
optional onError: (error, queuer) => void;

Defined in: async-queuer.ts:53

Optional error handler for when a task throws. If provided, the handler will be called with the error and queuer instance. This can be used alongside throwOnError - the handler will be called before any error is thrown.

Parameters

error

unknown

queuer

AsyncQueuer<TFn>

Returns

void


onExpire()?

ts
optional onExpire: (item, queuer) => void;
optional onExpire: (item, queuer) => void;

Defined in: async-queuer.ts:57

Callback fired whenever an item expires in the queuer

Parameters

item

TFn

queuer

AsyncQueuer<TFn>

Returns

void


onGetNextItem()?

ts
optional onGetNextItem: (item, queuer) => void;
optional onGetNextItem: (item, queuer) => void;

Defined in: async-queuer.ts:61

Callback fired whenever an item is removed from the queuer

Parameters

item

TFn

queuer

AsyncQueuer<TFn>

Returns

void


onIsRunningChange()?

ts
optional onIsRunningChange: (queuer) => void;
optional onIsRunningChange: (queuer) => void;

Defined in: async-queuer.ts:65

Callback fired whenever the queuer's running state changes

Parameters

queuer

AsyncQueuer<TFn>

Returns

void


onItemsChange()?

ts
optional onItemsChange: (queuer) => void;
optional onItemsChange: (queuer) => void;

Defined in: async-queuer.ts:69

Callback fired whenever an item is added or removed from the queuer

Parameters

queuer

AsyncQueuer<TFn>

Returns

void


onReject()?

ts
optional onReject: (item, queuer) => void;
optional onReject: (item, queuer) => void;

Defined in: async-queuer.ts:73

Callback fired whenever an item is rejected from being added to the queuer

Parameters

item

TFn

queuer

AsyncQueuer<TFn>

Returns

void


onSettled()?

ts
optional onSettled: (queuer) => void;
optional onSettled: (queuer) => void;

Defined in: async-queuer.ts:77

Optional callback to call when a task is settled

Parameters

queuer

AsyncQueuer<TFn>

Returns

void


onSuccess()?

ts
optional onSuccess: (result, queuer) => void;
optional onSuccess: (result, queuer) => void;

Defined in: async-queuer.ts:81

Optional callback to call when a task succeeds

Parameters

result

TFn

queuer

AsyncQueuer<TFn>

Returns

void


started?

ts
optional started: boolean;
optional started: boolean;

Defined in: async-queuer.ts:85

Whether the queuer should start processing tasks immediately or not.


throwOnError?

ts
optional throwOnError: boolean;
optional throwOnError: boolean;

Defined in: async-queuer.ts:91

Whether to throw errors when they occur. Defaults to true if no onError handler is provided, false if an onError handler is provided. Can be explicitly set to override these defaults.


wait?

ts
optional wait: number | (queuer) => number;
optional wait: number | (queuer) => number;

Defined in: async-queuer.ts:97

Time in milliseconds to wait between processing items. Can be a number or a function that returns a number.

Default

ts
0
0
Subscribe to Bytes

Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.

Bytes

No spam. Unsubscribe at any time.