new SafeBloomFilter(capacityopt, errorRateopt, bufferopt)
Bloom filter enforcing a given false positive error probabilty for a given capacity.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
capacity | number | <optional> | 20 | Max number of items allowed |
errorRate | number | <optional> | 0.1 | Max false positive error probabilty |
buffer | Buffer | <optional> | Underlying buffer to use |
- Source
Methods
add(key) → {boolean}
Adds item the the Bloom filter only if it is under capacity.
Parameters:
Name | Type | Description |
---|---|---|
key | string | | Item to add |
- Source
Returns:
wasAdded
- Type:
- boolean
has(key) → {boolean}
Checks if the given item probably exists in the Bloom filter.
Parameters:
Name | Type | Description |
---|---|---|
key | string | | Item to check |
- Source
Returns:
- Type:
- boolean
(static) destringify(data) → {SafeBloomFilter}
Create a SafeBloomFilter from an object
Parameters:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data | object | Properties
|
- Source
Returns:
- Type:
- SafeBloomFilter