bloomfilter
Advanced tools
Comparing version 0.0.17 to 0.0.18
{ | ||
"name": "bloomfilter", | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"license" : "BSD-3-Clause", | ||
"description": "Fast bloom filter in JavaScript.", | ||
@@ -5,0 +6,0 @@ "keywords": [ |
@@ -10,27 +10,29 @@ Bloom Filter | ||
var bloom = new BloomFilter( | ||
32 * 256, // number of bits to allocate. | ||
16 // number of hash functions. | ||
); | ||
```javascript | ||
var bloom = new BloomFilter( | ||
32 * 256, // number of bits to allocate. | ||
16 // number of hash functions. | ||
); | ||
// Add some elements to the filter. | ||
bloom.add("foo"); | ||
bloom.add("bar"); | ||
// Add some elements to the filter. | ||
bloom.add("foo"); | ||
bloom.add("bar"); | ||
// 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. | ||
bloom.test("foo"); | ||
bloom.test("bar"); | ||
bloom.test("blah"); | ||
// 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. | ||
bloom.test("foo"); | ||
bloom.test("bar"); | ||
bloom.test("blah"); | ||
// Serialisation. Note that bloom.buckets may be a typed array, | ||
// so we convert to a normal array first. | ||
var array = [].slice.call(bloom.buckets), | ||
json = JSON.stringify(array); | ||
// Serialisation. Note that bloom.buckets may be a typed array, | ||
// so we convert to a normal array first. | ||
var array = [].slice.call(bloom.buckets), | ||
json = JSON.stringify(array); | ||
// 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. | ||
var bloom = new BloomFilter(array, 3); | ||
// 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. | ||
var bloom = new BloomFilter(array, 16); | ||
``` | ||
@@ -37,0 +39,0 @@ Implementation |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7321
50