Skip to content
Buy me a coffee

RateLimiterControl

Defined in: src/window-rate-limiter.ts:271

Manual control of the rate limiters it is passed to (control option): penalty, reward, block, unblock, delete. key picks a partition of a partitioned limiter (omitted: every partition); single limiters ignore it. Pass it to the partitioned limiter, not to the per-key limiters it creates.

new RateLimiterControl(): RateLimiterControl

RateLimiterControl

block(duration, key?): void

Defined in: src/window-rate-limiter.ts:285

Reject everything (for key) for duration.

Duration

string

void


delete(key?): Promise<void>

Defined in: src/window-rate-limiter.ts:294

Forget the state of key (or of the single limiter): fresh quota, no block.

string

Promise<void>


penalty(points, key?): Promise<void>

Defined in: src/window-rate-limiter.ts:275

Charge points permits, e.g. for a failed login.

number

string

Promise<void>


reward(points, key?): Promise<void>

Defined in: src/window-rate-limiter.ts:280

Give points permits back; Infinity resets the count.

number

string

Promise<void>


unblock(key?): void

Defined in: src/window-rate-limiter.ts:289

string

void