UNPKG

idmp

Version:

A lightweight TypeScript library for deduplicating and caching async function calls with automatic retries, designed for idempotent network requests in React and Node.js.

17 lines (16 loc) 735 B
import { Idmp, IdmpOptions, IdmpPromise } from 'idmp'; type StorageType = 'localStorage' | 'sessionStorage'; declare const getCacheKey: (globalKey: string) => string; /** * Wrap an idmp instance with browser storage (localStorage or sessionStorage) for persistent caching * @param _idmp - Original idmp instance * @param storageType - Storage type to use, default is 'sessionStorage' * @returns Wrapped idmp instance with persistent caching */ declare const storageIdmpWrap: (_idmp: Idmp, storageType?: StorageType) => { <T>(globalKey: string, promiseFunc: IdmpPromise<T>, options?: IdmpOptions): Promise<T>; flush(globalKey: string): void; flushAll(): void; }; export default storageIdmpWrap; export { getCacheKey };