New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bloomfilter

Package Overview
Dependencies
Maintainers
0
Versions
17
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.19 to 0.0.20

75

bloomfilter.js
(function(exports) {
exports.BloomFilter = BloomFilter;
exports.fnv_1a = fnv_1a;

@@ -57,11 +56,39 @@ const typedArrays = typeof ArrayBuffer !== "undefined";

const r = this._locations;
const a = fnv_1a(v);
const b = fnv_1a_round(a);
const z = (fnv_1a_round(b) & 0x7fffffff) % m;
let x = (a & 0x7fffffff) % m;
let y = ((b & 0x7fffffff) % m) | 1;
let x;
let y;
// FNV-1a hash (64-bit).
{
const fnv64PrimeX = 0x01b3;
const l = v.length;
let t0 = 0, t1 = 0, t2 = 0, t3 = 0;
let v0 = 0x2325, v1 = 0x8422, v2 = 0x9ce4, v3 = 0xcbf2;
for (let i = 0; i < l; ++i) {
v0 ^= v.charCodeAt(i);
t0 = v0 * fnv64PrimeX; t1 = v1 * fnv64PrimeX; t2 = v2 * fnv64PrimeX; t3 = v3 * fnv64PrimeX;
t2 += v0 << 8; t3 += v1 << 8;
t1 += t0 >>> 16;
v0 = t0 & 0xffff;
t2 += t1 >>> 16;
v1 = t1 & 0xffff;
v3 = (t3 + (t2 >>> 16)) & 0xffff;
v2 = t2 & 0xffff;
}
x = (v3 << 16) | v2;
y = (v1 << 16) | v0;
}
x = (x % m);
if (x < 0) x += m;
y = (y % m);
if (y < 0) y += m;
// Force y to be odd to avoid catastrophic collisions where y is zero or divides m exactly (assuming m is a power of two).
y |= 1;
for (let i = 0; i < k; ++i) {
r[i] = x;
x = (x + y) % m;
y = (y + z) % m;
y = (y + i + 1) % m;
}

@@ -109,36 +136,2 @@ return r;

}
// Fowler/Noll/Vo hashing.
function fnv_1a(v) {
let a = 2166136261;
for (let i = 0; i < v.length; ++i) {
const c = v.charCodeAt(i);
const d = c & 0xff00;
if (d) {
a = fnv_multiply(a ^ d >> 8);
}
a = fnv_multiply(a ^ c & 0xff);
}
return fnv_mix(a);
}
// a * 16777619 mod 2**32
function fnv_multiply(a) {
return a + (a << 1) + (a << 4) + (a << 7) + (a << 8) + (a << 24);
}
// One additional iteration of FNV, given a hash.
function fnv_1a_round(a) {
return fnv_mix(fnv_multiply(a));
}
// See https://web.archive.org/web/20131019013225/http://home.comcast.net/~bretm/hash/6.html
function fnv_mix(a) {
a += a << 13;
a ^= a >>> 7;
a += a << 3;
a ^= a >>> 17;
a += a << 5;
return a & 0xffffffff;
}
})(typeof exports !== "undefined" ? exports : this);
{
"name": "bloomfilter",
"version": "0.0.19",
"version": "0.0.20",
"license": "BSD-3-Clause",

@@ -5,0 +5,0 @@ "description": "Fast bloom filter in JavaScript.",

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