Defined in: async-rate-limiter.ts:6
Options for configuring an async rate-limited function
• TFn extends AnyAsyncFunction
• TArgs extends Parameters<TFn>
optional enabled: boolean;
optional enabled: boolean;
Defined in: async-rate-limiter.ts:14
Whether the rate limiter is enabled. When disabled, maybeExecute will not trigger any executions. Defaults to true.
limit: number;
limit: number;
Defined in: async-rate-limiter.ts:18
Maximum number of executions allowed within the time window
optional onError: (error) => void;
optional onError: (error) => void;
Defined in: async-rate-limiter.ts:22
Optional error handler for when the rate-limited function throws
unknown
void
optional onExecute: (rateLimiter) => void;
optional onExecute: (rateLimiter) => void;
Defined in: async-rate-limiter.ts:26
Optional function to call when the rate-limited function is executed
AsyncRateLimiter<TFn, TArgs>
void
optional onReject: (rateLimiter) => void;
optional onReject: (rateLimiter) => void;
Defined in: async-rate-limiter.ts:30
Optional callback function that is called when an execution is rejected due to rate limiting
AsyncRateLimiter<TFn, TArgs>
void
window: number;
window: number;
Defined in: async-rate-limiter.ts:34
Time window in milliseconds within which the limit applies
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.