Skip to content

Commit

Permalink
Add types for getQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandr Borisov committed May 30, 2024
1 parent 560485e commit 111bb0d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased
* Expose requests queue via getQueue (see https://github.com/aishek/axios-rate-limit/pull/62)

## 1.3.3
* Fix axios dependency specification

Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ function axiosRateLimit (axios, options) {
var rateLimitInstance = new AxiosRateLimit(axios)
rateLimitInstance.setRateLimitOptions(options)

axios.getMaxRPS = AxiosRateLimit.prototype.getMaxRPS.bind(rateLimitInstance)
axios.getQueue = AxiosRateLimit.prototype.getQueue.bind(rateLimitInstance)
axios.getMaxRPS = AxiosRateLimit.prototype.getMaxRPS.bind(rateLimitInstance)
axios.setMaxRPS = AxiosRateLimit.prototype.setMaxRPS.bind(rateLimitInstance)
axios.setRateLimitOptions = AxiosRateLimit.prototype.setRateLimitOptions
.bind(rateLimitInstance)
Expand Down
23 changes: 14 additions & 9 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import { AxiosInstance } from 'axios';

export type RateLimitRequestHandler = {
resolve: () => boolean
}

export interface RateLimitedAxiosInstance extends AxiosInstance {
getMaxRPS: () => number,
setMaxRPS: (rps: number) => void,
setRateLimitOptions: (options: rateLimitOptions) => void,
// enable(axios: any): void,
// handleRequest(request:any):any,
// handleResponse(response: any): any,
// push(requestHandler:any):any,
// shiftInitial():any,
// shift():any
getQueue: () => RateLimitRequestHandler[],
getMaxRPS: () => number,
setMaxRPS: (rps: number) => void,
setRateLimitOptions: (options: rateLimitOptions) => void,
// enable(axios: any): void,
// handleRequest(request:any):any,
// handleResponse(response: any): any,
// push(requestHandler:any):any,
// shiftInitial():any,
// shift():any
}

export type rateLimitOptions = {
Expand Down

0 comments on commit 111bb0d

Please sign in to comment.