Delta-Pack - v0.2.9
    Preparing search index...

    Type Alias DeltaPackApi<T>

    The serialization API returned by load for a given schema type. Provides methods for encoding, decoding, delta compression, and object utilities.

    const GameState = ObjectType("GameState", {
    score: IntType(),
    players: ArrayType(StringType()),
    });

    const api: DeltaPackApi<{ score: number; players: string[] }> = load(GameState);

    const encoded = api.encode({ score: 100, players: ["alice"] });
    const decoded = api.decode(encoded);
    type DeltaPackApi<T> = {
        fromJson: (obj: object) => T;
        toJson: (obj: T) => Record<string, unknown>;
        encode: (obj: T) => Uint8Array;
        decode: (buf: Uint8Array) => T;
        encodeDiff: (a: T, b: T) => Uint8Array;
        decodeDiff: (a: T, diff: Uint8Array) => T;
        equals: (a: T, b: T) => boolean;
        clone: (obj: T) => T;
    }

    Type Parameters

    • T

      The TypeScript type that this API serializes

    Index

    Properties

    fromJson: (obj: object) => T

    Parse a JSON object into the typed representation, with lenient type coercion

    toJson: (obj: T) => Record<string, unknown>

    Convert a typed object to a JSON-serializable representation

    encode: (obj: T) => Uint8Array

    Encode an object to a compact binary format

    decode: (buf: Uint8Array) => T

    Decode a binary buffer back to an object

    encodeDiff: (a: T, b: T) => Uint8Array

    Encode only the differences between two objects (delta compression)

    decodeDiff: (a: T, diff: Uint8Array) => T

    Apply a delta to a base object to produce the updated object

    equals: (a: T, b: T) => boolean

    Deep equality comparison that respects float precision settings

    clone: (obj: T) => T

    Create a deep clone of an object