UNPKG

opstack-kit-chains

Version:
16 lines 606 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.withDedupe = exports.promiseCache = void 0; const lru_js_1 = require("../lru.js"); exports.promiseCache = new lru_js_1.LruMap(8192); function withDedupe(fn, { enabled = true, id }) { if (!enabled || !id) return fn(); if (exports.promiseCache.get(id)) return exports.promiseCache.get(id); const promise = fn().finally(() => exports.promiseCache.delete(id)); exports.promiseCache.set(id, promise); return promise; } exports.withDedupe = withDedupe; //# sourceMappingURL=withDedupe.js.map