Skip to content

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.

T

SerializedSnapshotSet<T>

The structure to restore, either statically typed or decoded as unknown.

SnapshotSet<T>

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.

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.

T

unknown

The structure to restore, either statically typed or decoded as unknown.

DeserializeSnapshotSetJsonOptions<T>

Runtime decoding options for untyped input.

SnapshotSet<T>

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.

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.

unknown

The structure to restore, either statically typed or decoded as unknown.

SnapshotSet<unknown>

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.