# Compression

Three compression algorithms with a unified static API. All implementations use `ArrayPool<byte>` and `stackalloc` for minimal GC pressure.

## Key Files

- **`BrotliHelper.cs`** — Brotli compress/decompress. Stack-allocates for small inputs, pools for large. `IsBrotliCompressed()` detection.
- **`GzipHelper.cs`** — GZip compress/decompress. Same API shape as BrotliHelper. `IsGzipCompressed()` checks magic bytes (0x1F, 0x8B).
- **`Lz4.cs`** — High-level LZ4 facade. Dispatches to Block or BlockArray mode via `Lz4CompressionMode`.
- **`Lz4Compressor.cs`** — Pure managed LZ4 block compressor. Hash table pattern matching (4K entries, 12-bit hash), MinMatch=4. WASM-compatible (no native dependencies).
- **`Lz4Decompressor.cs`** — LZ4 block/BlockArray decompressor. Handles overlapping copies for match references.
- **`Lz4CompressionMode.cs`** — Enum: `None`, `Block` (single), `BlockArray` (64KB chunked).

## LZ4 Modes

| Mode | Use Case |
|---|---|
| `Block` | Single contiguous block with 4-byte size header |
| `BlockArray` | Chunked (64KB default) for streaming/large data |

## Dependencies

- `System.IO.Compression` (Brotli, GZip)
- `System.Buffers` (ArrayPool)
