vue-admin-core
Version:
A Component Library for Vue 3
1 lines • 1.33 kB
Source Map (JSON)
{"version":3,"file":"cachePromise.mjs","sources":["../../../../../../package/hooks/useRequest/__utils__/cachePromise.ts"],"sourcesContent":["type CachedKey = string | number;\nconst cachePromise = new Map<CachedKey, Promise<any>>();\n\nconst getCachePromise = (cacheKey: CachedKey) => {\n return cachePromise.get(cacheKey);\n};\n\nconst setCachePromise = (cacheKey: CachedKey, promise: Promise<any>) => {\n // Should cache the same promise, cannot be promise.finally\n // Because the promise.finally will change the reference of the promise\n cachePromise.set(cacheKey, promise);\n\n // no use promise.finally for compatibility\n promise\n .then((res) => {\n cachePromise.delete(cacheKey);\n return res;\n })\n .catch(() => {\n cachePromise.delete(cacheKey);\n });\n};\n\nexport { getCachePromise, setCachePromise };\n"],"names":[],"mappings":"AACA,MAAM,YAAA,uBAAmB,GAA6B,EAAA,CAAA;AAEhD,MAAA,eAAA,GAAkB,CAAC,QAAwB,KAAA;AAC/C,EAAO,OAAA,YAAA,CAAa,IAAI,QAAQ,CAAA,CAAA;AAClC,EAAA;AAEM,MAAA,eAAA,GAAkB,CAAC,QAAA,EAAqB,OAA0B,KAAA;AAGtE,EAAa,YAAA,CAAA,GAAA,CAAI,UAAU,OAAO,CAAA,CAAA;AAGlC,EACG,OAAA,CAAA,IAAA,CAAK,CAAC,GAAQ,KAAA;AACb,IAAA,YAAA,CAAa,OAAO,QAAQ,CAAA,CAAA;AAC5B,IAAO,OAAA,GAAA,CAAA;AAAA,GACR,CACA,CAAA,KAAA,CAAM,MAAM;AACX,IAAA,YAAA,CAAa,OAAO,QAAQ,CAAA,CAAA;AAAA,GAC7B,CAAA,CAAA;AACL;;;;"}