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

@gmod/inflate

v1.0.0

Published

Fast DEFLATE decompression via wasm libdeflate, inlined as a single bundle

Readme

@gmod/inflate

NPM version Build Status

DEFLATE decompression through a wasm libdeflate build, shipped as one self-contained bundle with the wasm inlined as base64 — no separate .wasm fetch, no build tooling for consumers.

It exists for one shape in particular: a file holding hundreds of separately compressed blocks. inflateRawBatch inflates a whole run of them in a single JS↔wasm crossing, which is what the platform's DecompressionStream cannot do, and roughly 4x faster than pako on the block sizes genomics formats use.

Install

$ npm install @gmod/inflate

Usage

import { inflateRaw, inflateRawBatch } from '@gmod/inflate'

// One block, size known from an index
const plain = await inflateRaw(rawDeflateBytes, uncompressedSize)

// A run of blocks packed in one buffer — one crossing for all of them
const { data, offsets } = await inflateRawBatch(
  buffer, // concatenated compressed bytes
  new Uint32Array([0, 512, 1400]), // where each block starts
  new Uint32Array([512, 888, 640]), // how long each is
  65536, // the largest any one inflates to
)
for (let i = 0; i < offsets.length - 1; i++) {
  const block = data.subarray(offsets[i], offsets[i + 1])
}

The wasm module instantiates lazily on the first call and is shared from then on, so there is nothing to initialize and no teardown.

API

inflateRaw(input, outputSize): Promise<Uint8Array>

One raw deflate stream whose uncompressed size is already known. This is the path worth reaching for: libdeflate writes straight into an exactly-sized buffer with no growth loop and no streaming state. Formats that record the uncompressed size in their index — bigwig, .hic, bgzf — can always use it.

input must not include a zlib header. If your bytes start with one (0x78), pass input.subarray(2).

inflateRawUnknownSize(input): Promise<Uint8Array>

The same, when the size is not recorded. Doubles a guess until it fits, so it costs a re-inflate per doubling. Prefer inflateRaw where you can.

inflateRawBatch(inputs, offsets, lengths, maxBlockSize): Promise<BatchResult>

Many blocks, one call. inputs is the concatenated compressed bytes and offsets/lengths (both Uint32Array) locate each block within it. maxBlockSize is the largest size any single block inflates to.

Unlike inflateRaw, each block here is expected to carry its 2-byte zlib header; the wasm skips it internally.

Returns { data, offsets }, where data is every block's bytes concatenated and offsets has blocks + 1 marks, so block i is data.subarray(offsets[i], offsets[i + 1]).

Integrity

Raw deflate carries no checksum — zlib's adler32 lives in the 4-byte trailer these entry points skip past. A corruption that still forms a legal bit stream decodes to the wrong bytes without an error. Callers needing integrity should take it from their container: bgzf's per-block CRC, or a mismatch against the uncompressed size an index recorded.

Corrupt input that is not a legal stream rejects normally, and the wasm instance stays usable for later calls.

Why not DecompressionStream?

The platform has had one since 2023, and for a single large buffer it is a fine answer. For a file of many small blocks it is not: its cost is dominated by a fixed per-call overhead, and a caller must reach it once per block. Measured across three GMOD parsers, the container's shape decides the result:

| container | shape | vs wasm | | --------------------------------------------------------------------------------------------------------- | ---------------------------- | ------: | | bigwig | hundreds of small blocks | 4-11x | | .hic | fewer, larger blocks | ~2-7x | | bgzf | concatenated members, 1 call | ~2x |

inflateRawBatch is the answer to that per-call cost: it pays the crossing once for the whole group.

It is also only baseline since May 2023 (Safari 16.4, Firefox 113), so a fallback ships regardless — which removes the one remaining argument for it, the bundle saving.

Building

The tracked src/wasm/inflate-wasm-inlined.js is generated, and rebuilding it needs a Rust toolchain plus wasm-bindgen-cli:

$ pnpm build:wasm

It must rebuild byte-for-byte — preversion runs pnpm build, so a non-reproducible bundle would mean npm version quietly committing an artifact nobody reviewed, part-way through a release. git status clean after pnpm build:wasm is the check.

License

MIT