(key, fn)
| 38 | //#region src/state/keyed-mutex.ts |
| 39 | const locks = /* @__PURE__ */ new Map(); |
| 40 | function withKeyedLock(key, fn) { |
| 41 | const next = (locks.get(key) ?? Promise.resolve()).then(fn, fn); |
| 42 | const cleanup = next.then(() => {}, () => {}); |
| 43 | locks.set(key, cleanup); |
| 44 | cleanup.then(() => { |
| 45 | if (locks.get(key) === cleanup) locks.delete(key); |
| 46 | }); |
| 47 | return next; |
| 48 | } |
| 49 | |
| 50 | //#endregion |
| 51 | //#region src/functions/diagnostics.ts |
no test coverage detected