Use custom hashing functions
masterThe package uses xxh64 from @node-rs/xxhash by default. To use a custom hashing implementation, extend the Hashing class and override the serialize method. You can then apply this custom hashing logic to a data structure by assigning a new instance to the internal _hashing property.
const {BloomFilter, Hashing} = require('bloom-filters')
class CustomHashing extends Hashing {
serialize(_element, _seed) {
return BigInt(1)
}
}
const bl = BloomFilter.create(2, 0.01)
// override the hashing implementation locally
bl._hashing = new CustomHashing()
bl.add('a')