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

sketch-wasm

v0.1.2

Published

Probabilistic data structures for TypeScript/Node.js via WebAssembly

Downloads

2

Readme

sketch-wasm

A high-performance WebAssembly implementation of probabilistic data structures for TypeScript/Node.js applications. This library provides efficient implementations of:

  • Bloom Filters
  • Count-Min Sketch
  • HyperLogLog
  • Heavy Keeper (Approximate Top-K)

Features

  • 🚀 Blazing Fast: Up to 2,320x faster operations compared to pure JavaScript implementations
  • Written in Rust and compiled to WebAssembly for maximum performance
  • TypeScript bindings for easy integration
  • Memory-efficient implementations
  • Benchmarks comparing against popular JavaScript libraries

Performance

Our WebAssembly implementation significantly outperforms pure JavaScript alternatives:

Bloom Filter Performance

| Operation | WASM | JavaScript | Speedup | | -------------------- | ------- | ---------- | ---------------- | | Insert (100k items) | 14.53ms | 493.80ms | 34.0x faster | | Lookup (15k queries) | 4.67ms | 76.63ms | 16.4x faster |

Count-Min Sketch Performance

| Operation | WASM | JavaScript | Speedup | | ---------------------- | ------ | ---------- | ---------------- | | Increment (67k items) | 8.20ms | 221.39ms | 27.0x faster | | Estimate (10k queries) | 2.03ms | 45.10ms | 22.3x faster |

HyperLogLog Performance

| Operation | WASM | JavaScript | Speedup | | ---------------- | ------ | ----------- | ----------------- | | Add (100k items) | 5.96ms | 13,823.39ms | 2,320x faster | | Count estimation | 0.34ms | 1.18ms | 3.5x faster |

Heavy Keeper Performance

| Operation | WASM | JavaScript | Speedup | | ---------------- | ------ | ---------- | --------------- | | Add (3.3k items) | 2.91ms | 1.97ms | 0.7x slower | | Top-K query | 0.41ms | 0.45ms | 1.1x faster |

Benchmarks run against the popular bloom-filters npm package with 1M expected items and 1% false positive rate for Bloom Filter, width=10000/depth=5 for Count-Min Sketch, precision=14 for HyperLogLog, and width=1000/depth=5/k=10 for Heavy Keeper.

Installation

npm install sketch-wasm

Usage

Bloom Filter

import { BloomFilter } from 'sketch-wasm';

// Create a Bloom filter with expected 1M items and 1% false positive rate
const filter = new BloomFilter(1_000_000, 0.01);

// Insert items
filter.insert('item1');
filter.insert('item2');

// Check if items exist
console.log(filter.contains('item1')); // true
console.log(filter.contains('item2')); // true
console.log(filter.contains('item3')); // false (or true with 1% probability)

Count-Min Sketch

import { CountMinSketch } from 'sketch-wasm';

// Create a Count-Min Sketch with width=10000 and depth=5
const sketch = new CountMinSketch(10000, 5);

// Increment counters for items
sketch.increment('item1');
sketch.increment('item1');
sketch.increment('item2');

// Get frequency estimates
console.log(sketch.estimate('item1')); // ~2
console.log(sketch.estimate('item2')); // ~1
console.log(sketch.estimate('item3')); // 0

// Clear all counters
sketch.clear();

HyperLogLog

import { HyperLogLog } from 'sketch-wasm';

// Create a HyperLogLog with precision=14 (2^14 = 16384 registers)
const hll = new HyperLogLog(14);

// Add items
hll.add('item1');
hll.add('item2');
hll.add('item1'); // Duplicates are automatically handled

// Get cardinality estimate
console.log(hll.count()); // ~2

// Merge two HyperLogLog instances
const hll2 = new HyperLogLog(14);
hll2.add('item3');
hll.merge(hll2);
console.log(hll.count()); // ~3

Heavy Keeper (Approximate Top-K)

import { HeavyKeeper } from 'sketch-wasm';

// Create a Heavy Keeper with width=1000, depth=5, k=10, decay=0.9
const hk = new HeavyKeeper(1000, 5, 10, 0.9);

// Add items
for (let i = 0; i < 100; i++) {
  hk.add('frequent');
}
for (let i = 0; i < 50; i++) {
  hk.add('medium');
}
for (let i = 0; i < 10; i++) {
  hk.add('rare');
}

// Get top-k items
const topK = hk.top_k();
console.log(topK);
// [
//   { item: 'frequent', count: ~100 },
//   { item: 'medium', count: ~50 },
//   { item: 'rare', count: ~10 }
// ]

// Query specific item frequency
console.log(hk.query('frequent')); // ~100