-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbloomfilter_script_template_min.js
1 lines (1 loc) · 1.57 KB
/
bloomfilter_script_template_min.js
1
!function(t){t.BloomFilter=new o([LATEST_BLOOMFILTER_ARRAY],16),t.BloomFilterCount=[LATEST_BLOOMFILTER_COUNT],t.fnv_1a=i;var r="undefined"!=typeof ArrayBuffer;function o(t,o){var n;"number"!=typeof t&&(t=32*(n=t).length);var i=Math.ceil(t/32),e=-1;if(this.m=t=32*i,this.k=o,r){var s=1<<Math.ceil(Math.log(Math.ceil(Math.log(t)/Math.LN2/8))/Math.LN2),a=1===s?Uint8Array:2===s?Uint16Array:Uint32Array,f=new ArrayBuffer(s*o),h=this.buckets=new Int32Array(i);if(n)for(;++e<i;)h[e]=n[e];this._locations=new a(f)}else{h=this.buckets=[];if(n)for(;++e<i;)h[e]=n[e];else for(;++e<i;)h[e]=0;this._locations=[]}}function n(t){return 16843009*((t=(858993459&(t-=t>>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135)>>24}function i(t,r){for(var o=2166136261^(r||0),n=0,i=t.length;n<i;++n){var s=t.charCodeAt(n),a=65280&s;a&&(o=e(o^a>>8)),o=e(o^255&s)}return function(t){return t+=t<<13,t^=t>>>7,t+=t<<3,t^=t>>>17,4294967295&(t+=t<<5)}(o)}function e(t){return t+(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24)}o.prototype.locations=function(t){for(var r=this.k,o=this.m,n=this._locations,e=i(t),s=i(t,1576284489),a=e%o,f=0;f<r;++f)n[f]=a<0?a+o:a,a=(a+s)%o;return n},o.prototype.add=function(t){for(var r=this.locations(t+""),o=this.k,n=this.buckets,i=0;i<o;++i)n[Math.floor(r[i]/32)]|=1<<r[i]%32},o.prototype.test=function(t){for(var r=this.locations(t+""),o=this.k,n=this.buckets,i=0;i<o;++i){var e=r[i];if(0==(n[Math.floor(e/32)]&1<<e%32))return!1}return!0},o.prototype.size=function(){for(var t=this.buckets,r=0,o=0,i=t.length;o<i;++o)r+=n(t[o]);return-this.m*Math.log(1-r/this.m)/this.k}}("undefined"!=typeof exports?exports:this);