Interface SerializationAdapter

interface SerializationAdapter {
    getPayload(tag: number, value: any, options: SerializationOptions): any;
    getTag(value: any, options: SerializationOptions): undefined | number;
    getValue(tag: number, dehydratedPayload: any, options: SerializationOptions): any;
    hydrateValue?(tag: number, value: any, hydratedPayload: any, options: SerializationOptions): void;
}

Methods

  • Converts value into a serializable payload.

    The returned payload is dehydrated before serialization, so it can contain complex data structures and cyclic references. The payload is dehydrated during serialization. If the value itself is returned from this method, then the serialization would proceed as if no adapters were applied.

    Parameters

    • tag: number

      The tag returned by getTag for value.

    • value: any

      The value for which payload must be produced.

    • options: SerializationOptions

      Serialization options.

    Returns any

    The payload that is dehydrated and serialized.

  • Returns the unique tag of the value type, or undefined if the adapter doesn't recognize the type of the given value.

    Parameters

    Returns undefined | number

  • Returns the shallow value to which circular references from the payload may point. Otherwise, returns undefined if the adapter doesn't recognize the given tag.

    Parameters

    • tag: number

      The tag of the value type.

    • dehydratedPayload: any

      The payload that isn't hydrated yet.

    • options: SerializationOptions

      Serialization options.

    Returns any

  • Hydrates the value that was previously returned from the getValue method.

    Parameters

    • tag: number

      The tag of the value type.

    • value: any

      The value returned from the getValue method.

    • hydratedPayload: any

      The hydrated payload.

    • options: SerializationOptions

      Serialization options.

    Returns void