Skip to content

@eightkk/vue-weave / core / SnapshotCodec

Interface: SnapshotCodec<T> ​

Defined in: src/core/snapshot.ts:45

Stores values that JSON cannot represent (Date, BigInt, Map...) in application data. The stored form is { "$codec": id, "version": n, "value": ... }. Serializing needs matches and encode; restoring needs decode.

Type Parameters ​

T ​

T = any

Properties ​

decode? ​

optional decode?: (value, version) => T

Defined in: src/core/snapshot.ts:51

Parameters ​

value ​

JsonValue

version ​

number

Returns ​

T


encode? ​

optional encode?: (value) => JsonValue

Defined in: src/core/snapshot.ts:50

Parameters ​

value ​

T

Returns ​

JsonValue


id ​

id: string

Defined in: src/core/snapshot.ts:46


matches? ​

optional matches?: (value) => boolean

Defined in: src/core/snapshot.ts:49

Parameters ​

value ​

unknown

Returns ​

boolean


version? ​

optional version?: number

Defined in: src/core/snapshot.ts:48

Version written with each value, passed to decode on restore. Defaults to 1.

Released under the MIT License.