Defined in: rate-limiter.ts:6
Options for configuring a rate-limited function
• TFn extends AnyFunction
• TArgs extends Parameters<TFn>
optional enabled: boolean;
optional enabled: boolean;
Defined in: 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: rate-limiter.ts:18
Maximum number of executions allowed within the time window
optional onExecute: (rateLimiter) => void;
optional onExecute: (rateLimiter) => void;
Defined in: rate-limiter.ts:22
Callback function that is called after the function is executed
RateLimiter<TFn, TArgs>
void
optional onReject: (rateLimiter) => void;
optional onReject: (rateLimiter) => void;
Defined in: rate-limiter.ts:26
Optional callback function that is called when an execution is rejected due to rate limiting
RateLimiter<TFn, TArgs>
void
window: number;
window: number;
Defined in: rate-limiter.ts:30
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.