Package Exports
- zstdify
- zstdify/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (zstdify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
zstdify
Pure TypeScript zstd compression library. No native dependencies, works in Node.js and browsers.
Status
- Decoder: Raw and RLE blocks supported. Compressed blocks (Huffman/FSE) planned.
- Encoder: Raw baseline, RLE blocks for repeated-byte chunks (
level > 0), plus an initial compressed-block path (level > 1) for selected single-sequence blocks with raw fallback. - Format: RFC 8878 compliant for supported features.
Usage
import { compress, decompress } from 'zstdify';
const data = new TextEncoder().encode('hello world');
const compressed = compress(data);
const restored = decompress(compressed);
// restored equals dataAPI
compress(input: Uint8Array, options?: { level?: number }): Uint8Arraydecompress(input: Uint8Array, options?: { maxSize?: number }): Uint8Array
CLI Tool
The zstdify-cli package is a command-line tool for compressing and decompressing files with zstd. Install from npm:
pnpm add -g zstdify-clizstdify compress input.txt output.zst
zstdify extract output.zst restored.txtSee packages/cli/README.md for full CLI documentation.
Development
pnpm install
pnpm build
pnpm test
pnpm checkHow we validate
- Round-trip:
decompress(compress(x)) === xfor a variety of payloads and levels (see packages/zstdify-tests/src/roundtrip/), plus property-based tests with fast-check. - Conformance fixtures: Pre-generated
.zstfiles from the official zstd CLI; we decompress and compare. Legacy fixtures are documented in packages/zstdify-tests/fixtures/README.md. A decodecorpus-style corpus (multiple sizes/levels, manifest with hashes) is generated bypnpm --filter zstdify-tests run generate:corpusand tested inconformance/corpus-manifest.test.ts. - Differential (zstd ↔ zstdify): With the zstd CLI installed, we test zstd compress → zstdify decompress and zstdify compress → zstd decompress across payloads and levels.
- Corruption: Truncation, checksum mismatch, invalid header bits, and related error paths are tested in conformance/corruption.test.ts.
- Compression regression:
pnpm --filter zstdify-tests run regression:compressionchecks that compressed sizes for fixed payloads do not increase (ratio stability). - Fuzzing: A decompress harness (
pnpm --filter zstdify-tests run fuzz:decompress) reads bytes from stdin and callsdecompress; use with a fuzzer or corpus to find crashes. See upstream zstd TESTING.md and decodecorpus for comparison.
Publishing
Publish the npm packages (library first, then CLI so it gets the correct zstdify version):
pnpm make-release:zstdify
pnpm make-release:cliProject structure
packages/zstdify- Core librarypackages/cli- CLI tool (zstdify-clion npm)packages/zstdify-tests- Integration tests
License
MIT
Author
Ben Houston, Sponsored by Land of Assets