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

ThrottlerOptions

Interface: ThrottlerOptions<TFn>

Defined in: throttler.ts:48

Options for configuring a throttled function

Type Parameters

TFn extends AnyFunction

Properties

enabled?

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

Defined in: throttler.ts:54

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.


initialState?

ts
optional initialState: Partial<ThrottlerState<TFn>>;
optional initialState: Partial<ThrottlerState<TFn>>;

Defined in: throttler.ts:58

Initial state for the throttler


leading?

ts
optional leading: boolean;
optional leading: boolean;

Defined in: throttler.ts:63

Whether to execute on the leading edge of the timeout. Defaults to true.


onExecute()?

ts
optional onExecute: (throttler) => void;
optional onExecute: (throttler) => void;

Defined in: throttler.ts:67

Callback function that is called after the function is executed

Parameters

throttler

Throttler<TFn>

Returns

void


trailing?

ts
optional trailing: boolean;
optional trailing: boolean;

Defined in: throttler.ts:72

Whether to execute on the trailing edge of the timeout. Defaults to true.


wait

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

Defined in: throttler.ts:78

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

Our Partners
Unkey
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.

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.