Files
modules/state-crdts/hyper-p2p-crdt-pn-counter
2026-05-20 22:56:32 -04:00
..
2026-05-20 22:56:32 -04:00
2026-05-20 22:56:32 -04:00
2026-05-20 22:56:32 -04:00
2026-05-20 21:19:52 -04:00
2026-05-20 22:56:32 -04:00
2026-05-20 21:57:50 -04:00
2026-05-20 21:57:50 -04:00
2026-05-20 22:56:32 -04:00

hyper-p2p-crdt-pn-counter

Positive-negative counter CRDT (per-peer inc/dec, global sum).

Protocol: crdt-pn-counter/v1

When to use

  • Distributed counters (likes, queue depth estimates) with decrement support.
  • Sharded increments per peer without central coordination.

When not to use

  • Strict linearizable integers (use centralized or consensus module).
  • Set membership.

Quick start

const { HyperP2PCrdtPnCounter } = require('hyper-p2p-crdt-pn-counter')
const c = new HyperP2PCrdtPnCounter({ topic: 'metrics' })
await c.ready()
c.inc('peer-a')
c.dec('peer-b')
console.log(c.value())
await c.close()

Docs

Test

npm install && npm test