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

brotli-wasm-2

v0.0.3

Published

JavaScript bindings for Brotli compression compiled to WebAssembly

Readme

brotli-wasm-2

GitHub Actions License NPM version NPM package size

Documentation is available at this URL: https://npmx.dev/package-docs/brotli-wasm-2.

Installation

npm install brotli-wasm-2 # npm
yarn add brotli-wasm-2    # yarn
pnpm add brotli-wasm-2    # pnpm

Usage

Node.js or Browser

import { brotliCompress, brotliDecompress } from "brotli-wasm-2";

brotliCompress(new TextEncoder().encode("Hello world!"));
brotliCompress(new TextEncoder().encode("Hello world!"), {
  quality: 2,
  mode: "text",
});
brotliDecompress(brotliCompress(new TextEncoder().encode("Hello world!")));

This requires Node.js v24.0.5 or above (or Node.js v24.0.0 with flag --js-source-phase-imports) or Deno version v2.6 or higher. While Bun does not support source phase imports, it should work still since it supports fetching file URLs. In Webpack, make sure experiments.sourceImport is set to true. This is also supported on Cloudflare's workerd and Rollup.

WebAssembly ESM Integration

WebAssembly ESM integration is a a Phase 3 proposal that allows importing WebAsssembly files directly as ES modules. It is supported as of Node.js v24.0.5 (v24.0.0 with flag --experimental-wasm-modules) and Deno 2.1. It is supported in Webpack or Rspack by enabling experiments.asyncWebAssembly, in Rolldown via rolldown-plugin-wasm, and in Vite natively since v8.1.0. It can also be polyfilled via es-module-shims.

This may be preferred in some cases over the package entrypoint since V8 can cache WebAssembly code instantiated via streaming.

import { brotliCompress, brotliDecompress } from "brotli-wasm-2/brotli.wasm";

brotliCompress(new TextEncoder().encode("Hello world!"));
brotliCompress(new TextEncoder().encode("Hello world!"), {
  quality: 2,
  mode: "text",
});
brotliDecompress(brotliCompress(new TextEncoder().encode("Hello world!")));

Manual instantiation fallback

The previous syntaxes should work on most runtimes and some bundlers (e.g. Rollup); however, if you want to instantiate it manually and use the exports directly from the WebAssembly instance, you can do so like this:

Vite

import init from "brotli-wasm-2/brotli.wasm?init";
import { getImports } from "brotli-wasm-2/imports";

const instance = await init(getImports());
const { brotliCompress, brotliDecompress } =
  instance.exports as typeof import("brotli-wasm-2");

Remote URL

import { getImports } from "brotli-wasm-2/imports";

const instance = await WebAssembly.instantiateStreaming(
  fetch("https://esm.sh/brotli-wasm-2@%5E0.0.1/brotli.wasm"),
  getImports(),
);
const { brotliCompress, brotliDecompress } =
  instance.exports as typeof import("brotli-wasm-2");

Unwasm, Vercel Edge

import mod from "brotli-wasm-2/brotli.wasm?module";
import { getImports } from "brotli-wasm-2/imports";

const instance = WebAssembly.instantiate(mod, getImports());
const { brotliCompress } = instance.exports as typeof import("brotli-wasm-2");

License

This project is licensed under the MIT license. See the LICENSE file for details.