Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DefaultSerializer<T>

Default Serializer.

Supported types are a superset of JSON:

  • Primitive types (string, number, boolean, undefined, null)
  • Arrays and plain (non-class) objects, serialized recursively
  • CollabIDs (covered by the previous case since they are plain objects)
  • Uint8Array
  • Optional, with T serialized recursively.

All other types cause an error during serialize.

Construct using getInstance.

Type Parameters

  • T

Hierarchy

  • DefaultSerializer

Implements

Index

Methods

  • deserialize(message: Uint8Array): T
  • 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.

    Parameters

    • message: Uint8Array

    Returns T

  • serialize(value: T): Uint8Array
  • Returns a Uint8Array that is the serialized form of value.

    To recover the original value, use deserialize.

    Parameters

    • value: T

    Returns Uint8Array

  • Returns an instance of DefaultSerializer.

    Internally, all instances are the same literal object.

    Type Parameters

    • T

    Returns DefaultSerializer<T>

Generated using TypeDoc