Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bloomfilter

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bloomfilter - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

5

bloomfilter.js

@@ -8,8 +8,9 @@ (function(exports) {

// Creates a new bloom filter with *m* bits and *k* hashing functions.
function BloomFilter(m, k) {
this.m = m;
this.k = k;
var n = Math.ceil(m / k);
var n = Math.ceil(m / 32);
if (typedArrays) {
var buffer = new ArrayBuffer(4 * n),
var buffer = new ArrayBuffer(32 * n),
kbytes = 1 << Math.ceil(Math.log(Math.ceil(Math.log(m) / Math.LN2 / 8)) / Math.LN2),

@@ -16,0 +17,0 @@ array = kbytes === 1 ? Uint8Array : kbytes === 2 ? Uint16Array : Uint32Array,

2

package.json
{
"name": "bloomfilter",
"version": "0.0.6",
"version": "0.0.7",
"description": "Fast bloom filter in JavaScript.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -7,3 +7,25 @@ Bloom Filter

Although the bloom filter requires *n* hash functions, we can simulate this
Usage
-----
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");
// 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");
Implementation
--------------
Although the bloom filter requires *k* hash functions, we can simulate this
using only *two* hash functions. In fact, we cheat and get the second hash

@@ -10,0 +32,0 @@ function almost for free by iterating once more on the first hash using the FNV

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc