dbl-utils
Version:
Utilities for dbl, adba and others projects
32 lines (31 loc) • 1.03 kB
TypeScript
/**
* A queue to manage fetch requests with unique identification.
*/
export default class FetchQueue {
private queue;
private isRunning;
private fetchFn;
/**
*
* @param {Function} fetchFn - A fetch function (e.g., node-fetch or window.fetch).
*/
constructor(fetchFn: (url: string, options?: RequestInit) => Promise<any>);
/**
* Adds a fetch request to the queue.
* @param {string} url - The URL to fetch.
* @param {RequestInit} [options] - Optional fetch options.
* @returns {Promise<any>} - A promise that resolves with the fetch response.
*/
addRequest(url: string, options?: RequestInit): Promise<any>;
/**
* Runs the queue of fetch requests.
*/
private runQueue;
/**
* Creates a hash to uniquely identify a request.
* @param {string} url - The URL to fetch.
* @param {RequestInit} [options] - Optional fetch options.
* @returns {string} - A hash representing the unique request.
*/
private createHash;
}