RateLimiter Class
Signature
export declare class RateLimiter
Constructors
| Constructor | Description |
|---|---|
| (constructor)(maxRequests) | Constructs a new instance of the RateLimiter class |
Properties
| Property | Type | Description |
|---|---|---|
| release | () => void | |
| waitQueueLength | number |
Methods
| Method | Return Type | Description |
|---|---|---|
| acquire() | Promise<void> | |
| schedule(work) | Promise<T> |
Constructor Details
(constructor)
Constructs a new instance of the RateLimiter class
Signature
constructor(maxRequests: number);
Parameters
| Parameter | Type | Description |
|---|---|---|
| maxRequests | number |
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
| Parameter | Description |
|---|---|
| T |
Parameters
| Parameter | Type | Description |
|---|---|---|
| work | () => Promise<T> |
Returns
Return type: Promise<T>