bloomfilter-plus
A wrapper for bloomfilter, add some serialization features.
Basic usage
const BloomFilter = ; { // Test if an item is in our filter. // Returns true if an item is probably in the set, // or false if an item is definitely not in the set. console; console; console; console;} /* Just the same as the bloomfilter lib. */const bloom = 32 * 256 // number of bits to allocate. 3 // number of hash functions.; // Add some elements to the filter.bloom;bloom; console;; // Int32Arrayconst array = bloombuckets; // Deserialisation. Note that the any array-like object is supported, but// this will be used directly, so you may wish to use a typed array for// performance.const bloomFromArr = array 3;console;;
What's new
// Convert bloom buckets to buffer.const bytes = bloom;// Rebuild bloom from buffer.const bloomFromBytes = BloomFilter;console;; // Serialize bloom to a buffer with numHash desc.const serialized = bloom;// Deserialize bloom from serialized.const bloomDeserialized = BloomFilter;console;; // Create a best bloom filter for numElem & falsePositiveRateconst bestBf = BloomFilter;bestBf;bestBf;console;;