390e587709
* we don't want to break eviction checking for first item...continue the check * always include size when adding * scan for references and count them...request when found and don't clean up if referenced * add display of closure calculation * add always output to sandbox * formatting fixes * removed tracking of deferments, moved caching to separate concern and class * fixed cache checking and simplifed deferment * add tests for new deferment and cache * formatting * Update packages/objectloader2/src/deferment/BaseCache.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update packages/objectloader2/src/deferment/BaseCache.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update packages/objectloader2/src/core/objectLoader2.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update packages/objectloader2/src/core/objectLoader2.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update packages/objectloader2/src/core/objectLoader2.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix AI suggestions * rename BaseCache to MemoryCache * use private method --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
30 lines
558 B
TypeScript
30 lines
558 B
TypeScript
import { Base } from '../types/types.js'
|
|
|
|
export class DeferredBase {
|
|
private promise: Promise<Base>
|
|
private resolve!: (value: Base) => void
|
|
private reject!: (reason?: Error) => void
|
|
|
|
private readonly id: string
|
|
|
|
constructor(id: string) {
|
|
this.id = id
|
|
this.promise = new Promise<Base>((resolve, reject) => {
|
|
this.resolve = resolve
|
|
this.reject = reject
|
|
})
|
|
}
|
|
|
|
getId(): string {
|
|
return this.id
|
|
}
|
|
|
|
getPromise(): Promise<Base> {
|
|
return this.promise
|
|
}
|
|
|
|
found(value: Base): void {
|
|
this.resolve(value)
|
|
}
|
|
}
|