Defined in: async-throttler.ts:7
Options for configuring an async throttled function
• TFn extends AnyAsyncFunction
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.
optional leading: boolean;
optional leading: boolean;
Defined in: async-throttler.ts:18
Whether to execute the function immediately when called Defaults to true
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.
unknown
AsyncThrottler<TFn>
void
optional onSettled: (asyncThrottler) => void;
optional onSettled: (asyncThrottler) => void;
Defined in: async-throttler.ts:28
Optional function to call when the throttled function is executed
AsyncThrottler<TFn>
void
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
ReturnType<TFn>
AsyncThrottler<TFn>
void
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.
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: 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
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.