Skip to main content

Class: RateLimitManager<K>

Extends​

Type Parameters​

Type ParameterDefault type
Kstring

Constructors​

new RateLimitManager()​

new RateLimitManager<K>(time: number, limit: number): RateLimitManager<K>

Parameters​

ParameterTypeDefault 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.

Returns​

RateLimitManager<K>

Overrides​

Map<K, RateLimit<K>>.constructor

Defined in​

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

Properties​

[toStringTag]​

readonly [toStringTag]: string

Inherited from​

Map.[toStringTag]

Defined in​

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


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:12


size​

readonly size: number

Returns​

the number of elements in the Map.

Inherited from​

Map.size

Defined in​

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


sweepInterval​

private sweepInterval: undefined | null | Timeout

The interval to sweep expired ratelimits.

Defined in​

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


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:7


[species]​

readonly static [species]: MapConstructor

Inherited from​

Map.[species]

Defined in​

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


sweepIntervalDuration​

static sweepIntervalDuration: number = 30_000

The delay in milliseconds for RateLimitManager.sweepInterval.

Defined in​

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

Methods​

[iterator]()​

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

Returns an iterable of entries in the map.

Returns​

IterableIterator<[K, RateLimit<K>]>

Inherited from​

Map.[iterator]

Defined in​

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


acquire()​

acquire(id: K): RateLimit<K>

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

Parameters​

ParameterTypeDescription
idKThe id for the RateLimit

Returns​

RateLimit<K>

Defined in​

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


clear()​

clear(): void

Returns​

void

Inherited from​

Map.clear

Defined in​

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


create()​

create(id: K): RateLimit<K>

Creates a RateLimit for this manager.

Parameters​

ParameterTypeDescription
idKThe id the RateLimit belongs to

Returns​

RateLimit<K>

Defined in​

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


delete()​

delete(key: K): boolean

Parameters​

ParameterType
keyK

Returns​

boolean

true if an element in the Map existed and has been removed, or false if the element does not exist.

Inherited from​

Map.delete

Defined in​

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


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:124


forEach()​

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

Executes a provided function once per each key/value pair in the Map, in insertion order.

Parameters​

ParameterType
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:28


get()​

get(key: K): undefined | RateLimit<K>

Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.

Parameters​

ParameterType
keyK

Returns​

undefined | RateLimit<K>

Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.

Inherited from​

Map.get

Defined in​

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


has()​

has(key: K): boolean

Parameters​

ParameterType
keyK

Returns​

boolean

boolean indicating whether an element with the specified key exists or not.

Inherited from​

Map.has

Defined in​

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


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:129


set()​

set(id: K, value: RateLimit<K>): this

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

Parameters​

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

Returns​

this

Overrides​

Map.set

Defined in​

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


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:61


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:134


groupBy()​

static groupBy<K, T>(items: Iterable<T>, keySelector: (item: T, index: number) => K): Map<K, T[]>

Groups members of an iterable according to the return value of the passed callback.

Type Parameters​

Type Parameter
K
T

Parameters​

ParameterTypeDescription
itemsIterable<T>An iterable.
keySelector(item: T, index: number) => KA callback which will be invoked for each item in items.

Returns​

Map<K, T[]>

Inherited from​

Map.groupBy

Defined in​

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