1 | import { AxiosInstance } from "axios";
|
2 | export interface IRequestLimiterCallback {
|
3 | (axiosClient: AxiosInstance): Promise<any>;
|
4 | }
|
5 | export default class RequestLimiter {
|
6 | private max_requests;
|
7 | private interval;
|
8 | private axiosClient;
|
9 | private requests;
|
10 | private lastRequest;
|
11 | private timer;
|
12 | private queue;
|
13 | constructor(max_requests: number, interval: number, axiosClient: AxiosInstance | false);
|
14 | /**
|
15 | * Wrap the callable given by the user and wrap it in a promise
|
16 | * @param callable
|
17 | * @returns {Promise<any>}
|
18 | */
|
19 | private wrapCallable;
|
20 | |
21 |
|
22 |
|
23 | private check;
|
24 | |
25 |
|
26 |
|
27 | private setTimer;
|
28 | |
29 |
|
30 |
|
31 | private clearTimer;
|
32 | |
33 |
|
34 |
|
35 |
|
36 |
|
37 | run: any;
|
38 | }
|