UNPKG

cache-kit

Version:

A simple caching layer for fetch requests — supports memory, browser (localStorage), and Node.js (filesystem) adapters with smart strategies.

22 lines (19 loc) 706 B
interface CacheProps { revalidate?: number; strategy: 'cache-first' | 'network-first' | 'stale-while-revalidate'; adapter: 'memory' | 'browser' | 'node'; folderName?: string; } interface cacheDataType { expiredAt: number; response: Response; } interface cacheFunctionStructure { set: (key: string, data: cacheDataType) => void; get: (key: string) => cacheDataType | null; has: (key: string) => boolean; delete: (key: string) => void; clear: () => void; } declare const cachedFetch: (url: string, options: RequestInit, cacheOptions: CacheProps) => Promise<ResponseInit>; export { type CacheProps, type cacheDataType, type cacheFunctionStructure, cachedFetch };