axios-rate-limit 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -2
- package/typings/index.d.ts +9 -5
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "axios-rate-limit",
|
|
3
3
|
"description": "Rate limit for axios.",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/aishek/axios-rate-limit/issues"
|
|
@@ -11,9 +11,13 @@
|
|
|
11
11
|
"url": "https://github.com/aishek/axios-rate-limit.git"
|
|
12
12
|
},
|
|
13
13
|
"homepage": "https://github.com/aishek/axios-rate-limit#readme",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"axios": ">=0.18.0"
|
|
16
|
+
},
|
|
14
17
|
"devDependencies": {
|
|
18
|
+
"axios0": "npm:axios@^0.28.1",
|
|
19
|
+
"axios1": "npm:axios@^1.0.0",
|
|
15
20
|
"@logux/eslint-config": "28.1.0",
|
|
16
|
-
"axios": "^0.18.0",
|
|
17
21
|
"eslint": "^5.16.0",
|
|
18
22
|
"eslint-ci": "^1.0.0",
|
|
19
23
|
"eslint-config-standard": "^12.0.0",
|
package/typings/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
2
|
|
|
3
3
|
export interface RateLimitedAxiosInstance extends AxiosInstance {
|
|
4
|
-
getMaxRPS()
|
|
5
|
-
setMaxRPS(rps:number)
|
|
6
|
-
setRateLimitOptions(options: rateLimitOptions)
|
|
4
|
+
getMaxRPS: () => number,
|
|
5
|
+
setMaxRPS: (rps: number) => void,
|
|
6
|
+
setRateLimitOptions: (options: rateLimitOptions) => void,
|
|
7
7
|
// enable(axios: any): void,
|
|
8
8
|
// handleRequest(request:any):any,
|
|
9
9
|
// handleResponse(response: any): any,
|
|
@@ -12,7 +12,11 @@ export interface RateLimitedAxiosInstance extends AxiosInstance {
|
|
|
12
12
|
// shift():any
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
type rateLimitOptions = {
|
|
15
|
+
export type rateLimitOptions = {
|
|
16
|
+
maxRequests?: number,
|
|
17
|
+
perMilliseconds?: number,
|
|
18
|
+
maxRPS?: number
|
|
19
|
+
};
|
|
16
20
|
|
|
17
21
|
/**
|
|
18
22
|
* Apply rate limit to axios instance.
|
|
@@ -33,7 +37,7 @@ type rateLimitOptions = { maxRequests?: number, perMilliseconds?: number, maxRPS
|
|
|
33
37
|
* http.getMaxRPS() // 3
|
|
34
38
|
* http.setRateLimitOptions({ maxRequests: 6, perMilliseconds: 150 }) // same options as constructor
|
|
35
39
|
*
|
|
36
|
-
* @param {Object}
|
|
40
|
+
* @param {Object} axiosInstance axios instance
|
|
37
41
|
* @param {Object} options options for rate limit, available for live update
|
|
38
42
|
* @param {Number} options.maxRequests max requests to perform concurrently in given amount of time.
|
|
39
43
|
* @param {Number} options.perMilliseconds amount of time to limit concurrent requests.
|