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

snappy

v7.4.0

Published

Fastest Snappy compression library in Node.js

Readme

snappy

https://github.com/Brooooooklyn/snappy/actions Install size

!!! For [email protected] and below, please go to node-snappy.

More background about the 6-7 changes, please read this, Thanks @kesla .

🚀 Help me to become a full-time open-source developer by sponsoring me on Github

Fastest Snappy compression library in Node.js, powered by napi-rs and rust-snappy.

For small size data, snappyjs is faster, and it support browser. But it doesn't have async API, which is important for Node.js program.

Install this package

yarn add snappy

Support matrix

Node.js

engines.node is >= 10. CI tests Node 22 and Node 24.

Targets

| Rust triple | Platform | CI | | ------------------------------- | -------------------- | --------------------------------------- | | x86_64-pc-windows-msvc | Windows x64 | tested — node 22, 24 | | aarch64-pc-windows-msvc | Windows arm64 | tested — node 22, 24 | | i686-pc-windows-msvc | Windows x32 | built, not tested | | x86_64-apple-darwin | macOS x64 | tested — node 22, 24 | | aarch64-apple-darwin | macOS arm64 | tested — node 22, 24 | | x86_64-unknown-linux-gnu | Linux x64 gnu | tested — node 22, 24 | | x86_64-unknown-linux-musl | Linux x64 musl | tested — node 22, 24 | | aarch64-unknown-linux-gnu | Linux arm64 gnu | tested — node 22, 24 | | aarch64-unknown-linux-musl | Linux arm64 musl | tested — node 22, 24 | | armv7-unknown-linux-gnueabihf | Linux armv7 gnu | tested — node 22 only | | s390x-unknown-linux-gnu | Linux s390x | tested — node 22, 24 | | x86_64-unknown-freebsd | FreeBSD x64 | built, not tested | | powerpc64le-unknown-linux-gnu | Linux ppc64le | built, not tested | | riscv64gc-unknown-linux-gnu | Linux riscv64 | built, not tested | | aarch64-linux-android | Android arm64 | built, not tested | | arm-linux-androideabi | Android armv7 | built, not tested | | aarch64-unknown-linux-ohos | OpenHarmony arm64 | built, not tested | | wasm32-wasip1-threads | wasm32-wasi, browser | tested — node 24 (NAPI_RS_FORCE_WASI) |

Eighteen targets: eleven CI-tested, seven built but not exercised.

Browser

Bundlers resolve the wasm package through the browser export condition. The wasm build allocates shared memory and spawns worker threads, so SharedArrayBuffer must be available — the page has to be cross-origin isolated, served with Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp.

API

One-shot (raw Snappy block format)

export function compressSync(input: Buffer | string | ArrayBuffer | Uint8Array): Buffer
export function compress(input: Buffer | string | ArrayBuffer | Uint8Array): Promise<Buffer>
export function uncompressSync(compressed: Buffer): Buffer
export function uncompress(compressed: Buffer): Promise<Buffer>

Streaming (framed Snappy format)

Streaming uses the Snappy frame format (file extension .sz). This is not the same wire format as the one-shot APIs above — framed output cannot be passed to uncompress(), and raw blocks cannot be passed to the stream decompressors.

Incremental classes

import { Compressor, Decompressor } from 'snappy'

const compressor = new Compressor()
const parts = [compressor.update('Hello '), compressor.update('snappy 🚀'), await compressor.finish()]
const compressed = Buffer.concat(parts)

const decompressor = new Decompressor()
const restored = Buffer.concat([decompressor.update(compressed), await decompressor.finish()])
console.log(restored.toString('utf8')) // Hello snappy 🚀

The valid stream is the concatenation of every update() output plus the finish() tail.

Web Streams

import { compressStream, uncompressStream } from 'snappy'

const restored = uncompressStream(compressStream(source)) // ReadableStream<Uint8Array>

input must be a WHATWG ReadableStream; wrap a Node Readable with Readable.toWeb().

On wasm / browser builds the native transforms are unavailable; a buffered class-API polyfill is used automatically.

Node Duplex factories

import { createReadStream, createWriteStream } from 'node:fs'
import { createCompressStream, createUncompressStream } from 'snappy'

createReadStream('input.txt').pipe(createCompressStream()).pipe(createWriteStream('input.txt.sz'))

Requires a modern Node.js with Web Streams and Duplex.fromWeb (effectively Node 18+).

Performance

Hardware

OS: Windows 11 x86_64
Host: Micro-Star International Co., Ltd. MS-7C35
Kernel: 10.0.22000
Terminal: Windows Terminal
CPU: AMD Ryzen 9 5950X (32) @ 3.400GHz
Memory: 32688MiB

Result

Running "Compress" suite...
Progress: 100%

  snappy:
    4 220 ops/s, ±0.66%   | fastest

  snappy-v6:
    2 018 ops/s, ±0.84%   | 52.18% slower

  gzip:
    233 ops/s, ±0.52%     | slowest, 94.48% slower

  deflate:
    235 ops/s, ±0.45%     | 94.43% slower

  brotli:
    7 ops/s, ±0.51%       | slowest, 99.85% slower

Finished 4 cases!
  Fastest: snappy
  Slowest: brotli

Running "Decompress" suite...
Progress: 100%

  snappy:
    8 528 ops/s, ±1.03%   | fastest

  snappy-v6:
    6 357 ops/s, ±1.76%   | 25.46% slower

  gzip:
    1 406 ops/s, ±1.80%   | slowest, 83.51% slower

  deflate:
    1 435 ops/s, ±1.88%   | 83.17% slower

  brotli:
    1 208 ops/s, ±1.50%   | slowest, 86.99% slower

Finished 4 cases!
  Fastest: snappy
  Slowest: brotli