API reference › @evolu/common › RefCount › RefCountByKey
Defined in: packages/common/src/RefCount.ts:76
Reference counts keyed by logical identity.
By default, createRefCountByKey uses reference identity, the same as
Map keys. Callers may instead provide a lookup so logical
equality is based on a derived stable key. Decrementing a missing key is a
programmer error checked with assert.
Extends
Properties
[dispose]
readonly [dispose]: () => void;
Defined in: packages/common/src/RefCount.ts:98
Disposes and invalidates the helper. Further method calls throw.
Overrides
Disposable.[dispose]
decrement
readonly decrement: (key: TKey) => number & Brand<"Int"> & Brand<"NonNegative">;
Defined in: packages/common/src/RefCount.ts:86
Decrements key count and returns the new count.
Decrementing a missing key is a programmer error checked with assert.
getCount
readonly getCount: (key: TKey) => number & Brand<"Int"> & Brand<"NonNegative">;
Defined in: packages/common/src/RefCount.ts:89
Gets current count for key. Returns 0 when the key is not tracked.
has
readonly has: (key: TKey) => boolean;
Defined in: packages/common/src/RefCount.ts:92
Returns true when the key is tracked with count greater than zero.
increment
readonly increment: (key: TKey) => number & Brand<"Int"> & Brand<"NonNegative"> & Brand<"Positive">;
Defined in: packages/common/src/RefCount.ts:78
Increments key count and returns the new count.
keys
readonly keys: () => ReadonlySet<TKey>;
Defined in: packages/common/src/RefCount.ts:95
Returns all currently tracked keys.