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 🙏

© 2025 – Pkg Stats / Ryan Hefner

fast-bloom-filter

v2.1.1

Published

Fastest Bloom Filter on NPM. Powered by WASM, written in TypeScript & C.

Downloads

4,459

Readme

FAST-BLOOM-FILTER

License: ISC

The fastest Bloom Filter on npm.
Powered by WASM, written in TypeScript & C.


💡 What is a Bloom Filter?

A Bloom filter is a probabilistic set that guarantees no false negatives but tolerates unlikely false positives.

With n items, m bits and k hash functions the false-positive probability is P_fp ≈ (1 - e^{-kn/m})^k; using the near-optimal k ≈ (m/n) ln 2 yields m ≈ -(n ln p)/(ln 2)^2 bits to hit a target rate p (≈9.6 bits per element for p = 0.01).

🚀 Install

npm install fast-bloom-filter
# or
pnpm add fast-bloom-filter
# or
bun add fast-bloom-filter

🛠️ Usage

import FastBloomFilter from "fast-bloom-filter";

// Create a bloom filter for 100 elements with an expected false positive rate of 0.01
const bloomFilter = await FastBloomFilter.createOptimal(100, 0.01);
// Create a bloom filter of 100 bits with 4 hash rounds
//const bloomFilter = await FastBloomFilter.create(100, 4);

bloomFilter.addString("hello");
bloomFilter.add(Buffer.from([0x01, 0x02, 0x03]));

bloomFilter.hasString("hello"); // true
bloomFilter.has(Buffer.from([0x01, 0x02, 0x03])); // true
bloomFilter.hasString("foo"); // likely false
bloomFilter.has(Buffer.from([0x01, 0x02, 0x03, 0x04])); // likely false

const snapshot = bloomFilter.export();
bloomFilter.dispose();

const restored = await FastBloomFilter.import(snapshot);
restored.hasString("hello"); // true
restored.has(Buffer.from([0x01, 0x02, 0x03])); // true
restored.hasString("foo"); // likely false
restored.has(Buffer.from([0x01, 0x02, 0x03, 0x04])); // likely false
restored.dispose();

📐 Theory

📄 Burton H. Bloom (1970) Space/time trade-offs in hash coding with allowable errors

📄 Kirsch and Mitzenmacher (2006) Less Hashing, Same Performance: Building a Better Bloom Filter

📊 Benchmarks

Complete benchmark results

Timings are medians of 3 runs with GC before/after each run. For adapters without Buffer support, buffer datasets are base64-encoded strings.

strings N=1e5, M=2^21 (~2MB), K=10

  • N: 100,000 • Bits: 2,097,152 • K: 10 • Data: strings

| Adapter | Add Throughput | Has-hit Throughput | Has-miss Throughput | FP Rate | |:--|--:|--:|--:|--:| | FastBloomFilter | 24.28 Mops 100.0% of best | 24.33 Mops 100.0% of best | 22.25 Mops 100.0% of best | 0.00500% 80.0% of best | | bloomfilter | 11.00 Mops 45.3% of best | 10.25 Mops 42.1% of best | 10.88 Mops 48.9% of best | 0.00600% 66.7% of best | | @ably/bloomit | 1.348 Mops 5.6% of best | 1.399 Mops 5.7% of best | 1.834 Mops 8.2% of best | 0.00700% 57.1% of best | | blumea | 567.1 Kops 2.3% of best | 492.8 Kops 2.0% of best | 1.444 Mops 6.5% of best | 0.964% 0.4% of best | | bloom-filters | 339.4 Kops 1.4% of best | 345.4 Kops 1.4% of best | 360.1 Kops 1.6% of best | 0.00400% 100.0% of best | | bloom-filter | 215.5 Kops 0.9% of best | 219.2 Kops 0.9% of best | 1.272 Mops 5.7% of best | 0.00600% 66.7% of best |