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

    Function track

    • Wraps an object with deep tracking. Property changes are automatically tracked at each level with version numbers, enabling efficient diffs from arbitrary baseline snapshots.

      Note: The tracking system assumes a tree structure. If the same object is stored in multiple locations (shared references), dirty propagation will only work for the most recent parent assignment.

      Type Parameters

      • T extends object

      Parameters

      • obj: T

      Returns Tracked<T>

      const state = track({
      tick: 0,
      player: { x: 0, y: 0 },
      players: new Map([["p1", { x: 0, y: 0 }]]),
      });

      state.tick = 1; // Records version for "tick"
      state.player.x = 100; // Records version for "x", propagates to parent

      const snapshot1 = api.clone(state); // Captures current version

      state.tick = 2;
      const diff = api.encodeDiff(snapshot1, state); // Only includes changes since snapshot1