JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 380
  • Score
    100M100P100Q93796F
  • License MIT

Pure TypeScript zstd compression library

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

NPM Package NPM Downloads Tests Coverage

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 data

API

  • compress(input: Uint8Array, options?: { level?: number }): Uint8Array
  • decompress(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-cli
zstdify compress input.txt output.zst
zstdify extract output.zst restored.txt

See packages/cli/README.md for full CLI documentation.

Development

pnpm install
pnpm build
pnpm test
pnpm check

How we validate

  • Round-trip: decompress(compress(x)) === x for a variety of payloads and levels (see packages/zstdify-tests/src/roundtrip/), plus property-based tests with fast-check.
  • Conformance fixtures: Pre-generated .zst files 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 by pnpm --filter zstdify-tests run generate:corpus and tested in conformance/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:compression checks 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 calls decompress; 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:cli

Project structure

  • packages/zstdify - Core library
  • packages/cli - CLI tool (zstdify-cli on npm)
  • packages/zstdify-tests - Integration tests

License

MIT

Author

Ben Houston, Sponsored by Land of Assets