Call Signature
Section titled “Call Signature”deserializeHeapJson<
A>(payload,order):Heap<A>
Defined in: packages/heap/src/serialization/json.ts:121
Rebuild a heap from a SerializedHeap. O(n) time: one validation pass plus one array copy — the layout is adopted exactly, never reheapified, so a restored heap drains in the same sequence as the original.
Serialization is comparator-blind: the payload carries no order, so
restore re-supplies the base order used at construction — the
direction comes from the payload’s kind, not from reversing the order.
Round-trip fidelity holds when the re-supplied order is semantically
equivalent to the original; a different order that happens to satisfy
the payload’s layout is accepted, and the restored heap then follows the
order actually supplied. Comparator identity is the caller’s
responsibility in their envelope — a documented limitation, not a
validated fact.
Validation covers shape, kind, arity, the full heap invariant under the
direction-adjusted supplied order, and — with options — every element;
guards run before the order is ever invoked.
Type Parameters
Section titled “Type Parameters”A
Parameters
Section titled “Parameters”payload
Section titled “payload”A statically typed serialized heap, or decoded unknown
paired with runtime element validation.
Order<A>
The base order the heap was constructed under.
Returns
Section titled “Returns”Heap<A>
Throws
Section titled “Throws”When the payload is malformed or fails
validation: not an object (INVALID_SHAPE), a missing or unsupported
schema version (UNSUPPORTED_SCHEMA_VERSION), an unknown or cross-family
kind (UNKNOWN_KIND), a missing or mistyped nodes array
(MISSING_NODES), an unsafe or missing k-ary arity (INVALID_ARITY),
an element failing options.isElement (INVALID_ELEMENT), or a
parent-child pair violating the heap invariant
(HEAP_INVARIANT_VIOLATION, naming the offending index).
Call Signature
Section titled “Call Signature”deserializeHeapJson<
A>(payload,order,options):Heap<A>
Defined in: packages/heap/src/serialization/json.ts:122
Rebuild a heap from a SerializedHeap. O(n) time: one validation pass plus one array copy — the layout is adopted exactly, never reheapified, so a restored heap drains in the same sequence as the original.
Serialization is comparator-blind: the payload carries no order, so
restore re-supplies the base order used at construction — the
direction comes from the payload’s kind, not from reversing the order.
Round-trip fidelity holds when the re-supplied order is semantically
equivalent to the original; a different order that happens to satisfy
the payload’s layout is accepted, and the restored heap then follows the
order actually supplied. Comparator identity is the caller’s
responsibility in their envelope — a documented limitation, not a
validated fact.
Validation covers shape, kind, arity, the full heap invariant under the
direction-adjusted supplied order, and — with options — every element;
guards run before the order is ever invoked.
Type Parameters
Section titled “Type Parameters”A
Parameters
Section titled “Parameters”payload
Section titled “payload”unknown
A statically typed serialized heap, or decoded unknown
paired with runtime element validation.
Order<A>
The base order the heap was constructed under.
options
Section titled “options”Runtime decoding options for payloads whose element type is not yet known.
Returns
Section titled “Returns”Heap<A>
Throws
Section titled “Throws”When the payload is malformed or fails
validation: not an object (INVALID_SHAPE), a missing or unsupported
schema version (UNSUPPORTED_SCHEMA_VERSION), an unknown or cross-family
kind (UNKNOWN_KIND), a missing or mistyped nodes array
(MISSING_NODES), an unsafe or missing k-ary arity (INVALID_ARITY),
an element failing options.isElement (INVALID_ELEMENT), or a
parent-child pair violating the heap invariant
(HEAP_INVARIANT_VIOLATION, naming the offending index).
Call Signature
Section titled “Call Signature”deserializeHeapJson(
payload,order):Heap<unknown>
Defined in: packages/heap/src/serialization/json.ts:127
Rebuild a heap from a SerializedHeap. O(n) time: one validation pass plus one array copy — the layout is adopted exactly, never reheapified, so a restored heap drains in the same sequence as the original.
Serialization is comparator-blind: the payload carries no order, so
restore re-supplies the base order used at construction — the
direction comes from the payload’s kind, not from reversing the order.
Round-trip fidelity holds when the re-supplied order is semantically
equivalent to the original; a different order that happens to satisfy
the payload’s layout is accepted, and the restored heap then follows the
order actually supplied. Comparator identity is the caller’s
responsibility in their envelope — a documented limitation, not a
validated fact.
Validation covers shape, kind, arity, the full heap invariant under the
direction-adjusted supplied order, and — with options — every element;
guards run before the order is ever invoked.
Parameters
Section titled “Parameters”payload
Section titled “payload”unknown
A statically typed serialized heap, or decoded unknown
paired with runtime element validation.
Order<unknown>
The base order the heap was constructed under.
Returns
Section titled “Returns”Heap<unknown>
Throws
Section titled “Throws”When the payload is malformed or fails
validation: not an object (INVALID_SHAPE), a missing or unsupported
schema version (UNSUPPORTED_SCHEMA_VERSION), an unknown or cross-family
kind (UNKNOWN_KIND), a missing or mistyped nodes array
(MISSING_NODES), an unsafe or missing k-ary arity (INVALID_ARITY),
an element failing options.isElement (INVALID_ELEMENT), or a
parent-child pair violating the heap invariant
(HEAP_INVARIANT_VIOLATION, naming the offending index).