Handles requests that might get hit by a rate limit. Wraps around fetch and ensures that all users of the Requester only request a single time per 100 ms on top of the time it takes to load previous requests. Also runs on four "threads", allowing at least a certain level of asynchronicity.

Particularly used when a multitude of requests have a chance to DoS a service.

Constructors

Properties

fetch: ((input: URL | RequestInfo, init?: RequestInit) => Promise<Response>) & ((input: URL | RequestInfo, init?: RequestInit) => Promise<Response>) = ...
fetchActive: number = 0

Number of requests currently being processed. Must be lower than maxThreads.

fetchQueue: [[((data: Response) => void), ((reason?: any) => void)], any[]][] = []

Requests to be performed. Takes tuples containing a resolve-reject pair and arguments to be passed into the fetch function.

maxThreads: 4 = 4

Maximum number of requests to be processed simultaneously.

minTime: 100 = 100

Minimum amount of milliseconds to wait between each request.

Methods