first commit

This commit is contained in:
2026-05-29 08:20:56 +01:00
commit 949299f58d
6368 changed files with 527176 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
## String Diff
**Path:** `src/string-diff.ts`
**Export:** `calculateStringDiff`, `applyStringDiff`, `calculateDiffSavings`, `shouldUseDiff`, `StringDiff`
### What it does
Efficiently encodes string changes by finding common prefix and suffix, only encoding the differing middle section.
### Key API
| Function | Description |
|----------|-------------|
| `calculateStringDiff(previous, current)` | Compute `{ prefixLen, suffixLen, middleLen, middle }` |
| `applyStringDiff(previous, diff)` | Reconstruct current string from diff |
| `calculateDiffSavings(previous, current, diff)` | Percentage savings from diff encoding |
| `shouldUseDiff(previous, current, threshold?)` | Decide whether diff encoding is worthwhile |
### Format
`[prefixLen][suffixLen][middleLen][middleChars...]` — each length field is 1 byte.
### Used by
- Delta compression for string fields in game state
- Network protocols with repetitive string data