Serializer<From, To>: {
    description: string;
    deserialize: ((buffer: Uint8Array, offset?: number) => [To, number]);
    fixedSize: number | null;
    maxSize: number | null;
    serialize: ((value: From) => Uint8Array);
}

An object that can serialize and deserialize a value to and from a Uint8Array. It supports serializing looser types than it deserializes for convenience. For example, a bigint serializer will always deserialize to a bigint but can be used to serialize a number.

Type Parameters

  • From

    The type of the value to serialize.

  • To extends From = From

    The type of the deserialized value. Defaults to From.

Type declaration

  • description: string

    A description for the serializer.

  • deserialize: ((buffer: Uint8Array, offset?: number) => [To, number])
      • (buffer: Uint8Array, offset?: number): [To, number]
      • The function that deserializes a value from bytes. It returns the deserialized value and the number of bytes read.

        Parameters

        • buffer: Uint8Array
        • Optional offset: number

        Returns [To, number]

  • fixedSize: number | null

    The fixed size of the serialized value in bytes, or null if it is variable.

  • maxSize: number | null

    The maximum size a serialized value can be in bytes, or null if it is variable.

  • serialize: ((value: From) => Uint8Array)
      • (value: From): Uint8Array
      • The function that serializes a value into bytes.

        Parameters

        • value: From

        Returns Uint8Array

Generated using TypeDoc