Inverse of serialize.
Typically, this returns a deep clone of the original value, not the same literal reference. Indeed, it is impossible to return the original reference on a different replica.
Returns a Uint8Array that is the serialized form of value.
To recover the original value, use deserialize.
Generated using TypeDoc
A serializer for values of type
T
.Collabs with a generic type
T
, like CVar<T>
or CValueSet<T>
, need a Serializer<T> so that they can send values of typeT
from one replica to another.By default, all built-in Collabs use DefaultSerializer, which permits JSON values and some others. To use more general
T
or to optimize the encoding, you must supply your own Serializer<T>, typically in the Collab constructor'soptions
parameter.Serializers provided with the library (some only in package @collabs/core) include DefaultSerializer, CollabIDSerializer, StringSerializer, Uint8ArraySerializer, ArraySerializer, PairSerializer, and ConstSerializer.