Skip to content

Defined in: packages/rate-limit/src/rate-limit.ts:137

The options every built-in rate limiter accepts, whatever its kind.

The record is the same for three of the four kinds, so a caller can switch algorithm by changing the factory alone. Quantities are exact: a construction whose largest intermediate product would exceed Number.MAX_SAFE_INTEGER is rejected rather than approximated.

readonly capacity: number

Defined in: packages/rate-limit/src/rate-limit.ts:142

The most weight one instant can admit from a fresh state. A positive safe integer.


readonly windowDuration: number

Defined in: packages/rate-limit/src/rate-limit.ts:147

The width of the kind’s trailing window, in the milliseconds of clock. A positive safe integer.


readonly clock: Clock

Defined in: packages/rate-limit/src/rate-limit.ts:149

The time source the meter reads through, injected so a test replays every decision.