Skip to main content

Class: RateLimit<K>

Type parameters

Type parameterValue
Kstring

Constructors

new RateLimit()

new RateLimit<K>(manager: RateLimitManager<K>): RateLimit<K>

Parameters

ParameterTypeDescription
managerRateLimitManager<K>The manager for this entry.

Returns

RateLimit<K>

Source

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:22

Properties

expires

expires: number

The timestamp that represents when this entry will reset back to a available state.

Source

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:12


manager

private manager: RateLimitManager<K>

The RateLimitManager this entry is for.

Source

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:17


remaining

remaining: number

The remaining amount of times this entry can be dripped before the bucket is empty.

Source

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:7

Accessors

expired

get expired(): boolean

Whether this entry is expired or not, allowing the bucket to be reset.

Returns

boolean

Source

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:30


limited

get limited(): boolean

Whether this entry is limited or not.

Returns

boolean

Source

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:37


remainingTime

get remainingTime(): number

The remaining time in milliseconds before resetting.

Returns

number

Source

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:44

Methods

consume()

consume(): this

Consumes RateLimit.remaining by one if it's not limited, calling RateLimit.reset first if RateLimit.expired is true.

Returns

this

Source

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:51


reset()

reset(): this

Resets the entry back to it's full state.

Returns

this

Source

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:62


resetRemaining()

resetRemaining(): this

Resets the entry's RateLimit.remaining uses back to full state.

Returns

this

Source

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:69


resetTime()

resetTime(): this

Resets the entry's RateLimit.expires to the current time plus RateLimitManager.time.

Returns

this

Source

projects/utilities/packages/ratelimits/src/lib/RateLimit.ts:77