# jsbloom (英语)
使用 djb2 和 sdbm 算法在 JavaScript 中快速开花过滤器执行.
从 Less Hashing, 相同性能: 构建更好的 Bloom 过滤器 根据Adam Kirsch等人的著作 页:1 仅来自散列值 2个 独特的价值。 因此,产生两个独特的散列就足够了.
使用量
var filter = new JSBloom(items, false_probability_chance);
filter.addEntry("xyz");
filter.checkEntry("xyz"); // returns true
filter.checkEntry("yz"); // returns false
测试
测试用莫查和查伊
npm install mocha chai
mocha
参数
items: ceiling of entries to add
false_probability_chance: chance of false positives to occur
JSBloom will automatically generate the needed bit array and amount of hashes needed to meet your requirements.
API 参考
addEntry(str): adds str to bloom filter
addEntries(arr): iterates over arr and adds every entry within
checkEntry(str): checks if str in filter, returns false if definitely not, true if maybe
importData(base64, [number_of_hashes]): loads a base 64 LZW compressed Uint8Array
exportData(): returns base 64 encoded Uint8Array LZW as string
exportData(callback): returns the base 64 encoded Uint8Array LZW compressed to provided callback