diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b948af..69dad29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/index.js b/src/index.js index 543e92a..0b20c52 100644 --- a/src/index.js +++ b/src/index.js @@ -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) diff --git a/typings/index.d.ts b/typings/index.d.ts index 8bad104..4ef593e 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -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 = {