Ir al contenido
Español

GCounterMapOptions

Esta página aún no está disponible en tu idioma.

GCounterMapOptions<K> = object

Defined in: src/crdt/GCounterMap.ts:27

Map of grow-only counters — Map<K, GCounter> with a CRDT merge that takes the per-key max across replicas. The natural fit for “per-tag event count”, “per-route hit counter”, “per-user impression count” — anything where you want a separate counter per key but don’t want to manage one CRDT per dimension by hand.

const m = GCounterMap.empty() .increment(‘a’, ‘page-views’, 5) .increment(‘a’, ‘clicks’, 1); m.value(‘page-views’) // → 5 m.total() // → 6

Element identity. Same JSON-stringify default + identity override pattern as GSet / ORSet — necessary when keys are BigInt, Map, or other types that don’t round-trip through JSON.stringify. See GSet for the failure modes.

K

readonly optional identity?: (k) => string

Defined in: src/crdt/GCounterMap.ts:29

Custom identity for non-JSON-serialisable keys. See class doc.

K

string