npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

decode-zstd

v0.1.0

Published

small, dependency-free JavaScript Zstandard decompressor

Readme

decode-zstd

small, dependency-free JavaScript Zstandard decompressor

minimal example

import decodeZstd from 'decode-zstd'

const raw = decodeZstd(buffer)

features

  • Standard Zstandard frames, optional and unknown content sizes, every frame-header size encoding and all 16 skippable magic values.
  • Raw, run-length encoded and compressed blocks, including multi-block history.
  • Raw/RLE literals, Huffman literals with raw or FSE-compressed weights, one/four streams and treeless table reuse.
  • Predefined, RLE, compressed and repeated FSE sequence tables, all standard literal/match length codes and offset codes 0–31.
  • Repeat offsets, overlapping matches and frame-local state reset.
  • XXH64 content checksums with seed zero, using the required low 32 bits.
  • Block, window, sequence, entropy and exact-consumption validation, plus published decompressor errata regressions.

Streaming and custom dictionaries are intentionally out of scope. Nonzero dictionary IDs are rejected explicitly. Legacy Zstandard versions and the nonstandard magicless API format are not supported.

installation

npm install --save decode-zstd

usage

API

decodeZstd is available as both a default and named export.

import decodeZstd, {ZstdError} from 'decode-zstd'
import type {DecodeZstdOptions, ZstdErrorCode} from 'decode-zstd'

const raw = decodeZstd(compressed, {
  maxOutputSize: 64 * 1024 * 1024,
})
  • Input: Uint8Array or ArrayBuffer. Node/Bun Buffer works because it is a Uint8Array. Byte-offset views are respected. Other typed arrays and DataView are intentionally not accepted.
  • Output: a new exact-length Uint8Array containing the concatenated decoded bytes. It neither shares memory with nor modifies the input.
  • maxOutputSize: a nonnegative safe integer limiting total decoded bytes across all frames. The default is 2 ** 30 (1 073 741 824 bytes). Zero permits only empty output.
  • Framing: input must contain at least one complete standard or skippable frame. Concatenated frames are decoded in order and skippable frames produce no output.
  • Integrity: content checksums are verified whenever present.

The call is synchronous and retains the full result. maxOutputSize is an output budget, not a peak-memory limit. Buffer growth and final trimming may temporarily hold additional copies alongside compressed input and block scratch space. Choose a suitably small budget for untrusted input and use a Worker when decoding should not block a UI thread.

Errors

Malformed or unsupported compressed data throws ZstdError, whose code is one of:

| Code | Meaning | | --- | --- | | INVALID_DATA | Invalid framing, truncated data, invalid entropy tables/bitstreams, bad match history or a size mismatch. | | UNSUPPORTED_DICTIONARY | A nonzero dictionary ID was requested. | | OUTPUT_LIMIT | The output budget, safe-integer size range or a catchable allocation limit was exceeded. | | CHECKSUM_MISMATCH | The stored frame checksum disagrees with decoded content. |

Messages are diagnostic, not a stable parsing interface. Entropy failures preserve their underlying error as cause. Incorrect API argument types throw TypeError; invalid maxOutputSize values throw RangeError.

legal

Zstandard

adapted from Meta’s Zstandard reference implementation

Copyright © Meta Platforms, Inc. and affiliates – BSD

license

MIT License Copyright © 2026, Jaid <[email protected]> (https://github.com/jaid)