Skip to main content

Class: RateLimitManager<K>

ratelimits/src.RateLimitManager

Type parameters

NameType
Kstring

Hierarchy

Constructors

constructor

new RateLimitManager<K>(time, limit?)

Type parameters

NameType
Kstring

Parameters

NameTypeDefault valueDescription
timenumberundefinedThe amount of milliseconds for the ratelimits from this manager to expire.
limitnumber1The amount of times a RateLimit can drip before it's limited.

Overrides

Map<K, RateLimit<K\>\>.constructor

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:24

Properties

[toStringTag]

Readonly [toStringTag]: string

Inherited from

Map.__@toStringTag@73790

Defined in

node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:135


limit

Readonly limit: number

The amount of times a RateLimit can drip before it's limited.

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:13


size

Readonly size: number

Inherited from

Map.size

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:28


sweepInterval

Private sweepInterval: null | Timer

The interval to sweep expired ratelimits.

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:18


time

Readonly time: number

The amount of milliseconds for the ratelimits from this manager to expire.

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:8


[species]

Static Readonly [species]: MapConstructor

Inherited from

Map.__@species@73936

Defined in

node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:317


sweepIntervalDuration

Static sweepIntervalDuration: number = 30_000

The delay in milliseconds for RateLimitManager.sweepInterval.

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:76

Methods

[iterator]

[iterator](): IterableIterator<[K, RateLimit<K>]>

Returns an iterable of entries in the map.

Returns

IterableIterator<[K, RateLimit<K>]>

Inherited from

Map.__@iterator@73718

Defined in

node_modules/typescript/lib/lib.es2015.iterable.d.ts:121


acquire

acquire(id): RateLimit<K>

Gets a RateLimit from this manager or creates it if it does not exist.

Parameters

NameTypeDescription
idKThe id for the RateLimit

Returns

RateLimit<K>

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:35


clear

clear(): void

Returns

void

Inherited from

Map.clear

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:22


create

create(id): RateLimit<K>

Creates a RateLimit for this manager.

Parameters

NameTypeDescription
idKThe id the RateLimit belongs to

Returns

RateLimit<K>

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:43


delete

delete(key): boolean

Parameters

NameType
keyK

Returns

boolean

Inherited from

Map.delete

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:23


entries

entries(): IterableIterator<[K, RateLimit<K>]>

Returns an iterable of key, value pairs for every entry in the map.

Returns

IterableIterator<[K, RateLimit<K>]>

Inherited from

Map.entries

Defined in

node_modules/typescript/lib/lib.es2015.iterable.d.ts:126


forEach

forEach(callbackfn, thisArg?): void

Parameters

NameType
callbackfn(value: RateLimit<K>, key: K, map: Map<K, RateLimit<K>>) => void
thisArg?any

Returns

void

Inherited from

Map.forEach

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:24


get

get(key): undefined | RateLimit<K>

Parameters

NameType
keyK

Returns

undefined | RateLimit<K>

Inherited from

Map.get

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:25


has

has(key): boolean

Parameters

NameType
keyK

Returns

boolean

Inherited from

Map.has

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:26


keys

keys(): IterableIterator<K>

Returns an iterable of keys in the map

Returns

IterableIterator<K>

Inherited from

Map.keys

Defined in

node_modules/typescript/lib/lib.es2015.iterable.d.ts:131


set

set(id, value): RateLimitManager<K>

Wraps Collection's set method to set interval to sweep inactive RateLimits.

Parameters

NameTypeDescription
idKThe id the RateLimit belongs to
valueRateLimit<K>The RateLimit to set

Returns

RateLimitManager<K>

Overrides

Map.set

Defined in

projects/utilities/packages/ratelimits/src/lib/RateLimitManager.ts:54


sweep

sweep(): void

Wraps Collection's sweep method to clear the interval when this manager is empty.

Returns

void

Defined in

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


values

values(): IterableIterator<RateLimit<K>>

Returns an iterable of values in the map

Returns

IterableIterator<RateLimit<K>>

Inherited from

Map.values

Defined in

node_modules/typescript/lib/lib.es2015.iterable.d.ts:136