Socket
Socket
Sign inDemoInstall

bloom-filters

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bloom-filters - npm Package Compare versions

Comparing version 1.3.6 to 1.3.7

2

package.json
{
"name": "bloom-filters",
"version": "1.3.6",
"version": "1.3.7",
"description": "JS implementation of probabilistic data structures: Bloom Filter (and its derived), HyperLogLog, Count-Min Sketch, Top-K and MinHash",

@@ -5,0 +5,0 @@ "main": "dist/api.js",

@@ -180,19 +180,13 @@ /* file : utils.ts

}
function getDistinctIndicesBis (n: number, elem: HashableInput, size: number, count: number, indexes: Array<number> = []): Array<number> {
if (indexes.length === count) {
return indexes
} else {
const hashes = hashTwice(elem, true, seed! + size % n)
const ind = doubleHashing(n, hashes.first, hashes.second, size)
if (indexes.includes(ind)) {
// console.log('generate index: %d for %s', ind, elem)
return getDistinctIndicesBis(n + 1, elem, size, count, indexes)
} else {
// console.log('already found: %d for %s', ind, elem)
indexes.push(ind)
return getDistinctIndicesBis(n + 1, elem, size, count, indexes)
}
const indexes: Array<number> = []
let n = 1
while (indexes.length < number) {
const hashes = hashTwice(element, true, seed! + size + n)
const ind = doubleHashing(n, hashes.first, hashes.second, size)
if (!indexes.includes(ind)) {
indexes.push(ind)
}
n++
}
return getDistinctIndicesBis(1, element, size, number)
return indexes
}

@@ -199,0 +193,0 @@

@@ -29,3 +29,5 @@ /* file : utils-test.js

const utils = require('../dist/utils.js')
const { BloomFilter } = require('../dist/api.js')
const XXH = require('xxhashjs')
const { range } = require('lodash')
const seed = utils.getDefaultSeed()

@@ -115,2 +117,26 @@

})
describe('#getDistinctIndices', () => {
const key = "da5e21f8a67c4163f1a53ef43515bd027967da305ecfc741b2c3f40f832b7f82"
it('should return <number> distinct indices on the interval [0, size)', () => {
const desiredIndices = 10000
const result = range(0, desiredIndices, 1)
try{
const indices = utils.getDistinctIndices(key, desiredIndices, desiredIndices).sort((a, b) => a - b)
indices.should.deep.equal(result)
} catch (e) {
throw Error("it should not throw: " + e)
}
})
it('should the issue be fixed', () => {
try{
const filter = new BloomFilter(39, 28);
filter.add(key);
filter.has(key).should.be.true
} catch (e) {
throw Error("it should not throw: " + e)
}
})
})
})
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