diff --git a/src/hashing.ts b/src/hashing.ts index e5d42b8..3ce94af 100644 --- a/src/hashing.ts +++ b/src/hashing.ts @@ -1,5 +1,5 @@ import { xxh3 } from '@node-rs/xxhash' -import { bigIntToNumber, getBigIntAbs, numberToHex } from './utils.js' +import { getBigIntAbs, numberToHex } from './utils.js' import { TwoHashes, @@ -60,7 +60,11 @@ export default class Hashing { const arr = [] const hashes = this.hashTwice(element, seed) for (let i = 0; i < hashCount; i++) { - arr.push(Number(BigInt.asUintN(32, this.doubleHashing(i, hashes.first, hashes.second, size)))) + arr.push( + Number( + BigInt.asUintN(32, this.doubleHashing(i, hashes.first, hashes.second, size)), + ), + ) } if (arr.length !== hashCount) { throw new Error('Please report: wrong number of indexes') diff --git a/src/partitioned-bloom-filter.ts b/src/partitioned-bloom-filter.ts index 529876b..556a985 100644 --- a/src/partitioned-bloom-filter.ts +++ b/src/partitioned-bloom-filter.ts @@ -57,7 +57,11 @@ export default class PartitionedBloomFilter * @param errorRate - The desired error rate * @return A new PartitionedBloomFilter optimal for the given parameters */ - public static create(size: number, errorRate: number, nbHashes?: number): PartitionedBloomFilter { + public static create( + size: number, + errorRate: number, + nbHashes?: number, + ): PartitionedBloomFilter { const L = nbHashes ? nbHashes : Math.ceil(Math.log2(1 / errorRate)) const M = (size * Math.abs(Math.log(errorRate))) / Math.LN2 ** 2 // the optimal loadfactor is 0.5 for maximized size diff --git a/tests/cuckoo-filter.test.ts b/tests/cuckoo-filter.test.ts index e37a375..4be64f4 100644 --- a/tests/cuckoo-filter.test.ts +++ b/tests/cuckoo-filter.test.ts @@ -177,7 +177,7 @@ test('issue#(https://github.com/Callidon/bloom-filters/issues/9)', () => { // false positive rate should stay under the desired one let fp = 0 - let round = 10000 + const round = 10000 for (let i = 0; i < round; i++) { elems.forEach(e => { // should return false diff --git a/tests/scalable-bloom-filter.test.ts b/tests/scalable-bloom-filter.test.ts index 3ed1cab..d8e4480 100644 --- a/tests/scalable-bloom-filter.test.ts +++ b/tests/scalable-bloom-filter.test.ts @@ -41,12 +41,13 @@ test('should #has return correct values with added values', () => { fp++ } } - // the error rate is respected but it is still probabilities, + // the error rate is respected but it is still probabilities, // with a higher number of lookups the test is green // so we multiply by 10 to ensure the test pass // and also check it is around the desired error rate expect(fp / round).toBeLessThanOrEqual(10 * 2 * e) // compounded error probability is bounded by P <= 2 * P0 } catch (e) { + // eslint-disable-next-line no-console console.log(s) throw e }