axios-rate-limit 1.3.2 → 1.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "axios-rate-limit",
3
3
  "description": "Rate limit for axios.",
4
- "version": "1.3.2",
4
+ "version": "1.4.0",
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/src/index.js CHANGED
@@ -18,6 +18,10 @@ AxiosRateLimit.prototype.getMaxRPS = function () {
18
18
  return this.maxRequests / perSeconds
19
19
  }
20
20
 
21
+ AxiosRateLimit.prototype.getQueue = function () {
22
+ return this.queue
23
+ }
24
+
21
25
  AxiosRateLimit.prototype.setMaxRPS = function (rps) {
22
26
  this.setRateLimitOptions({
23
27
  maxRequests: rps,
@@ -155,6 +159,7 @@ function axiosRateLimit (axios, options) {
155
159
  var rateLimitInstance = new AxiosRateLimit(axios)
156
160
  rateLimitInstance.setRateLimitOptions(options)
157
161
 
162
+ axios.getQueue = AxiosRateLimit.prototype.getQueue.bind(rateLimitInstance)
158
163
  axios.getMaxRPS = AxiosRateLimit.prototype.getMaxRPS.bind(rateLimitInstance)
159
164
  axios.setMaxRPS = AxiosRateLimit.prototype.setMaxRPS.bind(rateLimitInstance)
160
165
  axios.setRateLimitOptions = AxiosRateLimit.prototype.setRateLimitOptions
@@ -1,15 +1,20 @@
1
1
  import { AxiosInstance } from 'axios';
2
2
 
3
+ export type RateLimitRequestHandler = {
4
+ resolve: () => boolean
5
+ }
6
+
3
7
  export interface RateLimitedAxiosInstance extends AxiosInstance {
4
- getMaxRPS: () => number,
5
- setMaxRPS: (rps: number) => void,
6
- setRateLimitOptions: (options: rateLimitOptions) => void,
7
- // enable(axios: any): void,
8
- // handleRequest(request:any):any,
9
- // handleResponse(response: any): any,
10
- // push(requestHandler:any):any,
11
- // shiftInitial():any,
12
- // shift():any
8
+ getQueue: () => RateLimitRequestHandler[],
9
+ getMaxRPS: () => number,
10
+ setMaxRPS: (rps: number) => void,
11
+ setRateLimitOptions: (options: rateLimitOptions) => void,
12
+ // enable(axios: any): void,
13
+ // handleRequest(request:any):any,
14
+ // handleResponse(response: any): any,
15
+ // push(requestHandler:any):any,
16
+ // shiftInitial():any,
17
+ // shift():any
13
18
  }
14
19
 
15
20
  export type rateLimitOptions = {