Umi — API References - v1.3.0
    Preparing search index...

    Type Alias Serializer<From, To>

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

    Type Parameters

    • From

      The type of the value to serialize.

    • To extends From = From

      The type of the deserialized value. Defaults to From.

    Index

    Properties

    description: string

    A description for the serializer.

    deserialize: (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.

    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

    The function that serializes a value into bytes.