Skip to main content
Version: v1

RateLimiter Class

Signature

export declare class RateLimiter

Constructors

ConstructorDescription
(constructor)(maxRequests)Constructs a new instance of the RateLimiter class

Properties

PropertyTypeDescription
release() => void
waitQueueLengthnumber

Methods

MethodReturn TypeDescription
acquire()Promise<void>
schedule(work)Promise<T>

Constructor Details

(constructor)

Constructs a new instance of the RateLimiter class

Signature

constructor(maxRequests: number);

Parameters

ParameterTypeDescription
maxRequestsnumber

Property Details

release

Signature

protected readonly release: () => void;

Type: () => void

waitQueueLength

Signature

get waitQueueLength(): number;

Type: number

Method Details

acquire

Signature

protected acquire(): Promise<void>;

Returns

Return type: Promise<void>

schedule

Signature

schedule<T>(work: () => Promise<T>): Promise<T>;
Type Parameters
ParameterDescription
T

Parameters

ParameterTypeDescription
work() => Promise<T>

Returns

Return type: Promise<T>