murmur-bloomfilter
It's a Bloom filter, implemented using murmur hash function.
A bloom filter has two methods: add()
and test()
. You
add()
an element and voodoo happens; you
test()
for an element and it returns false
if the element is definitely
not in the set, or true
if the element is probably in the set.
Installation
npm install murmur-bloomfilter --save
Usage:
var BloomFilter = ; //Simple Usage: create a filter with 1000 expected item and 0.01 false positive probability./*ie: if you are expecting to load 1000 items and you want to maintain a probability of not more than 0.01 false positives*///Recomendded: it will calculate the best setup for your need.var filter = 1000 001; // Add some keysfilterfilter; // Test themconsole; // trueconsole; // falseconsoleconsole; //true /// advanced mode : use your own parameters for filter size and hash count (m,k)var filter = m:1024k:2;filter;console; // true /// serialization interface:var filter = 1000 001;filter;filter; filter;
Implementation
Ported from geeksforgeeks.org tutourial.