5 lines
5.9 KiB
JavaScript
5 lines
5.9 KiB
JavaScript
|
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.MultiformatsMurmur3 = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
||
|
|
"use strict";var MultiformatsMurmur3=(()=>{var v=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var j=(t,r)=>{for(var e in r)v(t,e,{get:r[e],enumerable:!0})},J=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let c of G(r))!V.call(t,c)&&c!==e&&v(t,c,{get:()=>r[c],enumerable:!(n=C(r,c))||n.enumerable});return t};var K=t=>J(v({},"__esModule",{value:!0}),t);var vt={};j(vt,{murmur3128:()=>yt,murmur332:()=>bt,murmur364:()=>Lt});var At=new Uint8Array(0);var P=H,S=128,Q=127,W=~Q,X=Math.pow(2,31);function H(t,r,e){r=r||[],e=e||0;for(var n=e;t>=X;)r[e++]=t&255|S,t/=128;for(;t&W;)r[e++]=t&255|S,t>>>=7;return r[e]=t|0,H.bytes=e-n+1,r}var Y=M,Z=128,z=127;function M(t,n){var e=0,n=n||0,c=0,h=n,u,l=t.length;do{if(h>=l)throw M.bytes=0,new RangeError("Could not decode varint");u=t[h++],e+=c<28?(u&z)<<c:(u&z)*Math.pow(2,c),c+=7}while(u>=Z);return M.bytes=h-n,e}var k=Math.pow(2,7),tt=Math.pow(2,14),et=Math.pow(2,21),rt=Math.pow(2,28),nt=Math.pow(2,35),ot=Math.pow(2,42),ct=Math.pow(2,49),it=Math.pow(2,56),st=Math.pow(2,63),ft=function(t){return t<k?1:t<tt?2:t<et?3:t<rt?4:t<nt?5:t<ot?6:t<ct?7:t<it?8:t<st?9:10},at={encode:P,decode:Y,encodingLength:ft},ht=at,A=ht;function _(t,r,e=0){return A.encode(t,r,e),r}function U(t){return A.encodingLength(t)}function I(t,r){let e=r.byteLength,n=U(t),c=n+U(e),h=new Uint8Array(c+e);return _(t,h,0),_(e,h,n),h.set(r,c),new D(t,e,r,h)}var D=class{code;size;digest;bytes;constructor(r,e,n,c){this.code=r,this.size=e,this.digest=n,this.bytes=c}};var xt=20;function L({name:t,code:r,encode:e,minDigestLength:n,maxDigestLength:c}){return new B(t,r,e,n,c)}var B=class{name;code;encode;minDigestLength;maxDigestLength;constructor(r,e,n,c,h){this.name=r,this.code=e,this.encode=n,this.minDigestLength=c??xt,this.maxDigestLength=h}digest(r,e){if(e?.truncate!=null){if(e.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&e.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(r instanceof Uint8Array){let n=this.encode(r);return n instanceof Uint8Array?q(n,this.code,e?.truncate):n.then(c=>q(c,this.code,e?.truncate))}else throw Error("Unknown type, must be binary type")}};function q(t,r,e){if(e!=null&&e!==t.byteLength){if(e>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,e)}return I(r,t)}function g(t,r){let e=t.lo+r.lo>>>0,n=t.hi+r.hi+(e<t.lo?1:0)>>>0;return{lo:e,hi:n}}function dt(t,r){return t+r>>>0}function x(t,r){let e=t.lo&65535,n=t.lo>>>16,c=r.lo&65535,h=r.lo>>>16,u=e*c,l=e*h,o=n*c,s=n*h,f=(u>>>16)+(l&65535)+(o&65535)>>>0,y=(f<<16|u&65535)>>>0,w=s+(l>>>16)+(o>>>16)+(f>>>16),d=Math.imul(t.lo,r.hi),m=Math.imul(t.hi,r.lo),R=w+d+m>>>0;return{lo:y,hi:R}}function p(t,r){return Math.imul(t,r)>>>0}function b(t,r){if(r===0)return t;if(r===32)return{lo:t.hi,hi:t.lo};if(r<32){let c=(t.lo<<r|t.hi>>>32-r)>>>0,h=(t.hi<<r|t.lo>>>32-r)>>>0;return{lo:c,hi:h}}r-=32;let e=(t.hi<<r|t.lo>>>32-r)>>>0,n=(t.lo<<r|t.hi>>>32-r)>>>0;return{lo:e,hi:n}}function a(t,r){return{lo:(t.lo^r.lo)>>>0,hi:(t.hi^r.hi)>>>0}}function E(t,r){if(r===0)return t;if(r<32){let e=(t.lo>>>r|t.hi<<32-r)>>>0,n=t.hi>>>r;return{lo:e,hi:n}}return{lo:t.hi>>>r-32,hi:0}}function i(t,r){return{lo:t>>>0,hi:r>>>0}}function N(t,r){return(t<<r|t>>>32-r)>>>0}function F(t,r){let e=r*8,n=t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24,c=t[e+4]|t[e+5]<<8|t[e+6]<<16|t[e+7]<<24;return{lo:n>>>0,hi:c>>>0}}function mt(t,r){let e=r*4;return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}function O(t){return t=a(t,E(t,33)),t=x(t,i(3981806797,4283543511)),t=a(t,E(t,33)),t=x(t,i(444984403,3301882366)),t=a(t,E(t,33)),t}function gt(t){return t^=t>>>16,t=p(t,2246822507),t^=t>>>13,t=p(t,3266489909),t^=t>>>16,t}function T(t,r=0){let e=i(r,0),n=i(r,0),c=t.length,h=Math.floor(c/16),u=i(289559509,2277735313),l=i(658871167,1291169091);for(let w=0;w<h;w++){let d=F(t,w*2),
|
||
|
|
return MultiformatsMurmur3}));
|
||
|
|
//# sourceMappingURL=index.min.js.map
|