JSON Marshal - v0.0.5
    Preparing search index...

    Interface SerializationAdapter<Value, Payload>

    Adapter that serializes/deserializes Value as a Payload.

    interface SerializationAdapter<Value = any, Payload = any> {
        tag: number;
        canPack(value: any, options: Readonly<SerializationOptions>): boolean;
        hydrate?(
            value: Value,
            payload: Payload,
            options: Readonly<SerializationOptions>,
        ): void;
        pack(
            value: Value,
            options: Readonly<SerializationOptions>,
        ): Payload | undefined;
        unpack(
            payload: Dehydrated<Payload>,
            options: Readonly<SerializationOptions>,
        ): Value;
    }

    Type Parameters

    • Value = any

      The value to serialize.

    • Payload = any

      The payload that describes Value.

    Index

    Properties

    Methods

    Properties

    tag: number

    The integer tag of the value type.

    Tags must be unique among adapters that participate in serialization.

    Methods

    • Converts value into a serializable payload.

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

      If undefined is returned then value isn't serialized.

      Parameters

      Returns Payload | undefined

      The payload that is dehydrated and serialized.