Skip to content

Instantly share code, notes, and snippets.

View trophygeek's full-sized avatar

TomN trophygeek

  • San Francisco
  • 05:20 (UTC -07:00)
View GitHub Profile
@trophygeek
trophygeek / bloomFilterBigint.js
Last active October 18, 2023 14:27
Simple and easy to understand bloom filter in javascript for the browser. Uses BigInts and crypto.subtle.digest in 29 lines
/**
Simple and fast bloom filter (about 40 lines of actual code)
Uses build-in hash and BigInts to do work. Hash requires async/await
Meant for use in browser code not node
used like this:
// add to bloom
const bloomFilter = new BloomFilter();
bloomFilter.loadSaved(); // optional loading from localstorage