Download frontend/node_modules/next/dist/esm/lib/coalesced-function.js from netzkontrast/rag-context-optimizer: direct link, hf CLI and curl.
- Browser
- Download file 868 Bytes
-
https://huggingface.co/spaces/netzkontrast/rag-context-optimizer/resolve/main/frontend/node_modules/next/dist/esm/lib/coalesced-function.js
- Command line
-
hf download hf://spaces/netzkontrast/rag-context-optimizer/frontend/node_modules/next/dist/esm/lib/coalesced-function.js
-
curl -L -o coalesced-function.js https://huggingface.co/spaces/netzkontrast/rag-context-optimizer/resolve/main/frontend/node_modules/next/dist/esm/lib/coalesced-function.js
868 Bytes
| const globalInvokeCache = new Map(); | |
| export function withCoalescedInvoke(func) { | |
| return async function(key, args) { | |
| const entry = globalInvokeCache.get(key); | |
| if (entry) { | |
| return entry.then((res)=>({ | |
| isOrigin: false, | |
| value: res.value | |
| })); | |
| } | |
| async function __wrapper() { | |
| return await func.apply(undefined, args); | |
| } | |
| const future = __wrapper().then((res)=>{ | |
| globalInvokeCache.delete(key); | |
| return { | |
| isOrigin: true, | |
| value: res | |
| }; | |
| }).catch((err)=>{ | |
| globalInvokeCache.delete(key); | |
| return Promise.reject(err); | |
| }); | |
| globalInvokeCache.set(key, future); | |
| return future; | |
| }; | |
| } | |
| //# sourceMappingURL=coalesced-function.js.map |