@alwatr/fetch
Version:
`@alwatr/fetch` is an enhanced, lightweight, and dependency-free wrapper for the native `fetch` API. It provides modern features like caching strategies, request retries, timeouts, and intelligent duplicate request handling, all in a compact package.
34 lines • 1.42 kB
TypeScript
import type { AlwatrFetchOptions_, FetchOptions } from './type.js';
export declare const logger_: import("@alwatr/logger").AlwatrLogger;
/**
* A boolean flag indicating whether the browser's Cache API is supported.
*/
export declare const cacheSupported: boolean;
/**
* Internal-only fetch options type, which includes the URL and ensures all
* optional properties from AlwatrFetchOptions_ are present.
*/
type FetchOptions__ = AlwatrFetchOptions_ & Omit<RequestInit, 'headers'> & {
url: string;
};
/**
* Processes and sanitizes the fetch options.
*
* @param {string} url - The URL to fetch.
* @param {FetchOptions} options - The user-provided options.
* @returns {FetchOptions__} The processed and complete fetch options.
* @private
*/
export declare function _processOptions(url: string, options: FetchOptions): FetchOptions__;
/**
* Manages caching strategies for the fetch request.
* If the strategy is `network_only`, it bypasses caching and proceeds to the next step.
* Otherwise, it interacts with the browser's Cache API based on the selected strategy.
*
* @param {FetchOptions__} options - The fully configured fetch options.
* @returns {Promise<Response>} A promise resolving to a `Response` object, either from the cache or the network.
* @private
*/
export declare function handleCacheStrategy_(options: FetchOptions__): Promise<Response>;
export {};
//# sourceMappingURL=core.d.ts.map