Files
2026-06-09 21:06:27 +01:00

5.0 KiB

@suaveplan/bitpacker-delta - Bitpacker delta plugin

Summary

Delta encoding utilities for efficient repeated state transmission. Detects changes between successive values and encodes differences rather than full values.

Documentation tree

  • delta-manager — (no submodules)
  • delta-state — (no submodules)
  • index — Path: bitpacker-delta/src/index.ts Export: See source for details.
  • string-diff — Path: src/string-diff.ts Export: calculateStringDiff, applyStringDiff, calculateDiffSavings, `shouldUse…
  • xor-encoder — Path: src/xor-encoder.ts Export: calculateXorDelta, applyXorDelta, calculateDeltaBitSize, `isXorEfficie…
- [delta-manager](./src/delta-manager/delta-manager.md) — _(no submodules)_- [delta-state](./src/delta-state/delta-state.md) — _(no submodules)_- [delta-state](./src/delta-state/delta-state.md) — _(no submodules)_- [index](./src/index.md) — **Path:** `bitpacker-delta/src/index.ts` **Export:** See source for details.
  • string-diff — Path: src/string-diff.ts Export: calculateStringDiff, applyStringDiff, calculateDiffSavings, `shouldUse…
  • xor-encoder — Path: src/xor-encoder.ts Export: calculateXorDelta, applyXorDelta, calculateDeltaBitSize, `isXorEfficie…
  • delta-manager — (no submodules)- delta-state — (no submodules)- delta-state — (no submodules)- index — Path: bitpacker-delta/src/index.ts Export: See source for details.
  • string-diff — Path: src/string-diff.ts Export: calculateStringDiff, applyStringDiff, calculateDiffSavings, `shouldUse…
  • xor-encoder — Path: src/xor-encoder.ts Export: calculateXorDelta, applyXorDelta, calculateDeltaBitSize, `isXorEfficie…
  • delta-manager — (no submodules)- delta-state — (no submodules)- delta-state — (no submodules)- index — Path: bitpacker-delta/src/index.ts Export: See source for details.
  • string-diff — Path: src/string-diff.ts Export: calculateStringDiff, applyStringDiff, calculateDiffSavings, `shouldUse…
  • xor-encoder — Path: src/xor-encoder.ts Export: calculateXorDelta, applyXorDelta, calculateDeltaBitSize, `isXorEfficie…
  • delta-manager — (no submodules)- delta-state — (no submodules) - delta-state — (no submodules)- index — Path: bitpacker-delta/src/index.ts Export: See source for details.
  • string-diff — Path: src/string-diff.ts Export: calculateStringDiff, applyStringDiff, calculateDiffSavings, `shouldUse…
  • xor-encoder — Path: src/xor-encoder.ts Export: calculateXorDelta, applyXorDelta, calculateDeltaBitSize, `isXorEfficie…

Install

bun add @suaveplan/bitpacker-delta

Usage

import { DeltaManager, calculateStringDiff, applyStringDiff, numberXor } from "@suaveplan/bitpacker-delta";

// Change detection
const dm = new DeltaManager();
dm.detectChanges({ x: 1, y: 2 }); // returns { x: 1, y: 2 }
dm.detectChanges({ x: 1, y: 2 }); // returns undefined (no change)
dm.detectChanges({ x: 1, y: 3 }); // returns { x: 1, y: 3 }

// String diff
const diff = calculateStringDiff("hello world", "hello there");
// { prefixLen: 6, suffixLen: 0, middleLen: 5, middle: "there" }
const reconstructed = applyStringDiff("hello world", diff);
// "hello there"

// Numeric XOR delta
const delta = numberXor(3.14159, 2.71828);

Modules

  • src/index.ts — DeltaManager, change detection API
  • src/xor-encoder.ts — XOR-based numeric delta encoding
  • src/string-diff.ts — Common prefix/suffix string diff encoding