Skip to content

serializeChangeNodeForJSON

serializeChangeNodeForJSON<TIn, TOut>(node, encodeLeaf): CRDTChangeNodeWire<TOut>

Defined in: packages/core/src/merkle-dag-serialization.ts:121

Iteratively serialize a CRDTChangeNode tree by transforming each node’s change payload via the provided encoder, preserving the kind and children structure for round-tripping through JSON.

A children value equal to crdtChangeNodeDeferred (i.e. false) is preserved verbatim so deferred subtrees survive the round-trip.

The output is intentionally byte-identical (modulo the leaf encoding) to the input shape so peers running this code interoperate with peers using the prior per-provider helpers.

TIn

Input leaf payload type (e.g. Uint8Array or Uint8Array[]).

TOut

Output leaf payload type (e.g. string or string[]).

CRDTChangeNode<TIn>

The change node tree to serialize.

(leaf) => TOut

Function that maps an input leaf payload to its JSON-serializable representation.

CRDTChangeNodeWire<TOut>