Call Signature
Section titled “Call Signature”deserializeSnapshotSetJson<
T>(serialized):SnapshotSet<T>
Defined in: packages/snapshot-set/src/serialization/json.ts:177
Rebuild a SnapshotSet from a SerializedSnapshotSet. O(k + m) time, where k is the number of registered values and m is the total number of toggle entries.
A round trip through serializeSnapshotSetJson and deserializeSnapshotSetJson preserves kind,
size, values() order, and every hasAt/valuesAt answer for every id
minted before serialization — including ids the caller held onto. A further
createSnapshot() on the restored structure mints an id greater than every
restored id, because the version counter is restored exactly, not
recomputed by replaying add/delete.
Untyped input produces a SnapshotSet<unknown>. Pass a value type guard to
validate decoded values and recover a narrower value type.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”serialized
Section titled “serialized”The structure to restore, either statically typed or
decoded as unknown.
Returns
Section titled “Returns”SnapshotSet<T>
Throws
Section titled “Throws”When the serialized shape is malformed: a
non-object payload, an unknown kind, a values/history length
mismatch, a version or toggle-version entry that is not a non-negative safe
integer, a history entry that is empty or not strictly increasing, a
history or snapshot entry above version, a value’s first toggle version
not strictly greater than the previous value’s, a duplicate value, or (with
options.isValue supplied) a value that fails validation. Distinguish
causes with error.code, one of SnapshotSetErrorCode.
Call Signature
Section titled “Call Signature”deserializeSnapshotSetJson<
T>(serialized,options):SnapshotSet<T>
Defined in: packages/snapshot-set/src/serialization/json.ts:178
Rebuild a SnapshotSet from a SerializedSnapshotSet. O(k + m) time, where k is the number of registered values and m is the total number of toggle entries.
A round trip through serializeSnapshotSetJson and deserializeSnapshotSetJson preserves kind,
size, values() order, and every hasAt/valuesAt answer for every id
minted before serialization — including ids the caller held onto. A further
createSnapshot() on the restored structure mints an id greater than every
restored id, because the version counter is restored exactly, not
recomputed by replaying add/delete.
Untyped input produces a SnapshotSet<unknown>. Pass a value type guard to
validate decoded values and recover a narrower value type.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”serialized
Section titled “serialized”unknown
The structure to restore, either statically typed or
decoded as unknown.
options
Section titled “options”DeserializeSnapshotSetJsonOptions<T>
Runtime decoding options for untyped input.
Returns
Section titled “Returns”SnapshotSet<T>
Throws
Section titled “Throws”When the serialized shape is malformed: a
non-object payload, an unknown kind, a values/history length
mismatch, a version or toggle-version entry that is not a non-negative safe
integer, a history entry that is empty or not strictly increasing, a
history or snapshot entry above version, a value’s first toggle version
not strictly greater than the previous value’s, a duplicate value, or (with
options.isValue supplied) a value that fails validation. Distinguish
causes with error.code, one of SnapshotSetErrorCode.
Call Signature
Section titled “Call Signature”deserializeSnapshotSetJson(
serialized):SnapshotSet<unknown>
Defined in: packages/snapshot-set/src/serialization/json.ts:182
Rebuild a SnapshotSet from a SerializedSnapshotSet. O(k + m) time, where k is the number of registered values and m is the total number of toggle entries.
A round trip through serializeSnapshotSetJson and deserializeSnapshotSetJson preserves kind,
size, values() order, and every hasAt/valuesAt answer for every id
minted before serialization — including ids the caller held onto. A further
createSnapshot() on the restored structure mints an id greater than every
restored id, because the version counter is restored exactly, not
recomputed by replaying add/delete.
Untyped input produces a SnapshotSet<unknown>. Pass a value type guard to
validate decoded values and recover a narrower value type.
Parameters
Section titled “Parameters”serialized
Section titled “serialized”unknown
The structure to restore, either statically typed or
decoded as unknown.
Returns
Section titled “Returns”SnapshotSet<unknown>
Throws
Section titled “Throws”When the serialized shape is malformed: a
non-object payload, an unknown kind, a values/history length
mismatch, a version or toggle-version entry that is not a non-negative safe
integer, a history entry that is empty or not strictly increasing, a
history or snapshot entry above version, a value’s first toggle version
not strictly greater than the previous value’s, a duplicate value, or (with
options.isValue supplied) a value that fails validation. Distinguish
causes with error.code, one of SnapshotSetErrorCode.