// Share only work currently in flight. Results are never cached here. export class SingleFlight { constructor(){this.pending=new Map();} run(key,work){if(this.pending.has(key))return this.pending.get(key);const promise=Promise.resolve().then(work).finally(()=>{if(this.pending.get(key)===promise)this.pending.delete(key);});this.pending.set(key,promise);return promise;} invalidate(key){this.pending.delete(key);} clear(){this.pending.clear();} }