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

AsyncThrottlerOptions

Interface: AsyncThrottlerOptions<TFn>

Defined in: async-throttler.ts:7

Options for configuring an async throttled function

Type Parameters

TFn extends AnyAsyncFunction

Properties

enabled?

ts
optional enabled: boolean | (throttler) => boolean;
optional enabled: boolean | (throttler) => boolean;

Defined in: async-throttler.ts:13

Whether the throttler is enabled. When disabled, maybeExecute will not trigger any executions. Can be a boolean or a function that returns a boolean. Defaults to true.


leading?

ts
optional leading: boolean;
optional leading: boolean;

Defined in: async-throttler.ts:18

Whether to execute the function immediately when called Defaults to true


onError()?

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

Defined in: async-throttler.ts:24

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

Parameters

error

unknown

asyncThrottler

AsyncThrottler<TFn>

Returns

void


onSettled()?

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

Defined in: async-throttler.ts:28

Optional function to call when the throttled function is executed

Parameters

asyncThrottler

AsyncThrottler<TFn>

Returns

void


onSuccess()?

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

Defined in: async-throttler.ts:32

Optional function to call when the throttled function is executed

Parameters

result

ReturnType<TFn>

asyncThrottler

AsyncThrottler<TFn>

Returns

void


throwOnError?

ts
optional throwOnError: boolean;
optional throwOnError: boolean;

Defined in: async-throttler.ts:41

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.


trailing?

ts
optional trailing: boolean;
optional trailing: boolean;

Defined in: async-throttler.ts:46

Whether to execute the function on the trailing edge of the wait period Defaults to true


wait

ts
wait: number | (throttler) => number;
wait: number | (throttler) => number;

Defined in: async-throttler.ts:52

Time window in milliseconds during which the function can only be executed once. Can be a number or a function that returns a number. Defaults to 0ms

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.