@moq/json
v0.0.3
Published
Snapshot/delta JSON publishing over MoQ tracks using RFC 7396 JSON Merge Patch.
Downloads
585
Readme
@moq/json
Snapshot/delta JSON publishing over Media over QUIC tracks using RFC 7396 JSON Merge Patch.
A JSON value is published over a @moq/net track as a series of groups. Each group is self-contained: its first frame is a full snapshot and any following frames are JSON Merge Patch deltas applied in order. A consumer jumps to the newest group, reads the snapshot, and applies the deltas, so a late joiner never needs older groups.
Deltas are opt-in via maxDeltaRatio (omit it to publish a full snapshot per group).
Quick Start
npm add @moq/jsonimport { Producer, Consumer } from "@moq/json";
// Publish: deltas off by default (one snapshot per group).
const producer = new Producer(track);
producer.update({ hello: "world" });
// Consume: yields the reconstructed value after each update.
const consumer = new Consumer(track);
for await (const value of consumer) {
console.log(value);
}Pass { deltaRatio: x } to Producer to emit merge-patch deltas while a group stays within x times the size of a fresh snapshot. Arrays are replaced wholesale within a delta; a value set to null falls back to a snapshot, since merge patch reads null as a key deletion.
