export default PromiseCache; /** * Caches promises while they are pending * Serves to dedupe equal queries requested at the same time */ declare class PromiseCache { /** * Holds pending promises * * @type {Object.} */ pending: { [x: string]: Promise; }; /** * Tries to find a pending promise corresponding to the result of keyFunc * - If not found, promiseFunc is executed and the resulting promise is stored while it's pending * - If found, it is immediately returned * * @template T * @param {function(): Promise} promiseFunc - Not executed only if an "equal" promise is already pending. * @param {function(): string} keyFunc - Returns a key to find in cache to find a pending promise. * @returns {Promise} */ exec(promiseFunc: () => Promise, keyFunc: () => string): Promise; /** * * @param {function(): string} keyFunc - Returns a key to find in cache to find a pending promise. * @returns {Promise | null} */ get(keyFunc: () => string): Promise | null; }