INNER CODE UNIT · TypeScript
Resources
babyfish-ct/graphql-ts-client · api/src/DependencyManager.ts:218
class Resources {
private refCountMap = new Map<string, number>();
retain(resource: string) {
this.refCountMap.set(resource, (this.refCountMap.get(resource) ?? 0) + 1);
}
release(resource: string): number {
const refCount = this.refCountMap.get(resource);
if (refCount !== undefined) {
if (refCount > 1) {
this.refCountMap.set(resource, refCount - 1);
} else {
this.refCountMap.delete(resource);
}
}
return this.refCountMap.size;