Class: BloomFilter

BloomFilter

Bloom Filter is a probabilistic data structure used to test if an element is a member of a set or not. False positives are possible but false negatives or not i.e. if the answer to mightContain(e) is false, then the element is definetly not in the set. But if the answer is true, then the element may still not be in the set For more details see this tutorial

new BloomFilter(config)

Parameters:
Name Type Argument Description
config Object <optional>

An object with following properies

  {
    expectedInsertions: The number of expected insertions in the filter, default is 1024,

    falsePosPercent: Acceptable false positive rate, default is 0.03,

    hashGenerator: Optional Hash Generator, By default
    the library provides a MD5 based hash generation. The hash generation uses node's crypto library.
    A single 128 bit hash is created which is then used to create different hashes.
    [See Less Hashing, Same Performance](http://www.eecs.harvard.edu/~kirsch/pubs/bbbf/esa06.pdf)
    }
Source:

Methods

mightContain(obj) → {Boolean}

Parameters:
Name Type Description
obj *

element to check for presence

Source:
Returns:

true if all hashes of object are present in the Set, false otherwise

Type
Boolean

put(obj)

Parameters:
Name Type Description
obj *

element to add to the filter The element being added is first "stringified" and then added to the filter. If the element is an string, it is used as is. If the element is a Number, it is converted to string. If the element is an Array, all elements of the array are recursively "stringified" and joined. If the element is an Object, it is checked if the object contains a function "stringify", if yes that function is invoked and the resulting string is used. For all other cases, default toString() is used.

Source: