Skip to main content

Class: RateLimitManager<K>

@sapphire/ratelimits.RateLimitManager

Type parameters

NameType
Kstring

Hierarchy

Constructors

constructor

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

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.

Returns

RateLimitManager<K>

Overrides

Map&lt;K, RateLimit&lt;K&gt;&gt;.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

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]

Static Readonly [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): 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: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): 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:42


delete

delete(key): boolean

Parameters

NameType
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, thisArg?): void

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

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


get

get(key): 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

NameType
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): boolean

Parameters

NameType
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, value): this

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

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

groupBy<K, T>(items, keySelector): Map<K, T[]>

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

Type parameters

Name
K
T

Parameters

NameTypeDescription
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