Socket
Socket
Sign inDemoInstall

xxhashjs

Package Overview
Dependencies
1
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.4 to 0.0.5

bower.json

28

build/xxhash.lmd.js

@@ -719,3 +719,3 @@ // This file was automatically generated from "xxhash.lmd.json"

* @method update
* @param {String|Buffer} input as a string or nodejs Buffer
* @param {String|Buffer|ArrayBuffer} input as a string or nodejs Buffer or ArrayBuffer
* @return ThisExpression

@@ -725,2 +725,10 @@ */

var isString = typeof input == 'string'
var isArrayBuffer
if (input instanceof ArrayBuffer)
{
isArrayBuffer = true
input = new Uint8Array(input);
}
var p = 0

@@ -734,3 +742,12 @@ var len = input.length

if (this.memsize == 0) this.memory = isString ? '' : new Buffer(16)
if (this.memsize == 0)
{
if (isString) {
this.memory = ''
} else if (isArrayBuffer) {
this.memory = new Uint8Array(16)
} else {
this.memory = new Buffer(16)
}
}

@@ -742,2 +759,4 @@ if (this.memsize + len < 16) // fill in tmp buffer

this.memory += input
} else if (isArrayBuffer) {
this.memory.set( input.subarray(0, len), this.memsize )
} else {

@@ -756,2 +775,4 @@ input.copy( this.memory, this.memsize, 0, len )

this.memory += input.slice(0, 16 - this.memsize)
} else if (isArrayBuffer) {
this.memory.set( input.subarray(0, 16 - this.memsize), this.memsize )
} else {

@@ -865,2 +886,4 @@ input.copy( this.memory, this.memsize, 0, 16 - this.memsize )

this.memory += input.slice(p)
} else if (isArrayBuffer) {
this.memory.set( input.subarray(p, bEnd), this.memsize )
} else {

@@ -958,3 +981,4 @@ input.copy( this.memory, this.memsize, p, bEnd )

})(this)
})
},{},{});

2

build/xxhash.min.lmd.js

@@ -1,1 +0,1 @@

(function(e,t,n,r,i){var s={},o=function(t){return e.Function("return "+t)()},u=e.document,a,f=function(t,i){var o={exports:{}};s[t]=1,n[t]=o.exports;if(!i)i=i||e[t];else if(typeof i=="function"){var u=l;r[t]&&r[t].sandbox&&typeof u=="function"&&(u=a),i=i(u,o.exports,o)||o.exports}return i=i,n[t]=i},l=function(e){var t=n[e],r=[e,t];return r&&(e=r[0],t=r[1]),s[e]&&t?t:(typeof t=="string"&&t.indexOf("(function(")===0&&(t=o(t)),f(e,t))},c={exports:{}};for(var h in n)s[h]=0;t(l,c.exports,c)})(this,function(e,t,n){window.XXH=e("xxhash")},{"./lib/uint32":function(e,t,n){(function(e){function t(e,n){if(!(this instanceof t))return new t(e,n);this._low=0,this._high=0,this.remainder=null;if(typeof n=="undefined")return i.call(this,e);if(typeof e=="string")return s.call(this,e,n);r.call(this,e,n)}function r(e,t){return this._low=e|0,this._high=t|0,this}function i(e){return this._low=e&65535,this._high=e>>>16,this}function s(e,t){var n=parseInt(e,t||10);return this._low=n&65535,this._high=n>>>16,this}var o={36:t(Math.pow(36,5)),16:t(Math.pow(16,7)),10:t(Math.pow(10,9)),2:t(Math.pow(2,30))},u={36:t(36),16:t(16),10:t(10),2:t(2)};t.prototype.fromBits=r,t.prototype.fromNumber=i,t.prototype.fromString=s,t.prototype.toNumber=function(){return this._high<<16|this._low},t.prototype.toString=function(e){e=e||10;var n=u[e]||new t(e);if(!this.gt(n))return this.toNumber().toString(e);var r=this.clone(),i=new Array(32);for(var s=31;s>=0;s--){r.div(n),i[s]=r.remainder.toNumber().toString(e);if(!r.gt(n))break}return i[s-1]=r.toNumber().toString(e),i.join("")},t.prototype.add=function(e){var t=this._low+e._low,n=t>>>16;return n+=this._high+e._high,this._low=t&65535,this._high=n&65535,this},t.prototype.subtract=function(e){return this.add(e.clone().negate())},t.prototype.multiply=function(e){var t=this._high,n=this._low,r=e._high,i=e._low,s,o;return o=n*i,s=o>>>16,s+=t*i,s&=65535,s+=n*r,this._low=o&65535,this._high=s&65535,this},t.prototype.div=function(e){if(e._low==0&&e._high==0)throw Error("division by zero");if(e._high==0&&e._low==1)return this.remainder=new t(0),this;if(e.gt(this))return this.remainder=new t(0),this._low=0,this._high=0,this;if(this.eq(e))return this.remainder=new t(0),this._low=1,this._high=0,this;var n=e.clone(),r=-1;while(!this.lt(n))n.shiftLeft(1,!0),r++;this.remainder=this.clone(),this._low=0,this._high=0;for(;r>=0;r--)n.shiftRight(1),this.remainder.lt(n)||(this.remainder.subtract(n),r>=16?this._high|=1<<r-16:this._low|=1<<r);return this},t.prototype.negate=t.prototype.not=function(){var e=(~this._low&65535)+1;return this._low=e&65535,this._high=~this._high+(e>>>16)&65535,this},t.prototype.equals=t.prototype.eq=function(e){return this._low==e._low&&this._high==e._high},t.prototype.greaterThan=t.prototype.gt=function(e){return this._high>e._high?!0:this._high<e._high?!1:this._low>e._low},t.prototype.lessThan=t.prototype.lt=function(e){return this._high<e._high?!0:this._high>e._high?!1:this._low<e._low},t.prototype.or=function(e){return this._low|=e._low,this._high|=e._high,this},t.prototype.and=function(e){return this._low&=e._low,this._high&=e._high,this},t.prototype.xor=function(e){return this._low^=e._low,this._high^=e._high,this},t.prototype.shiftRight=t.prototype.shiftr=function(e){return e>16?(this._low=this._high>>e-16,this._high=0):e==16?(this._low=this._high,this._high=0):(this._low=this._low>>e|this._high<<16-e&65535,this._high>>=e),this},t.prototype.shiftLeft=t.prototype.shiftl=function(e,t){return e>16?(this._high=this._low<<e-16,this._low=0,t||(this._high&=65535)):e==16?(this._high=this._low,this._low=0):(this._high=this._high<<e|this._low>>16-e,this._low=this._low<<e&65535,t||(this._high&=65535)),this},t.prototype.rotateLeft=t.prototype.rotl=function(e){var t=this._high<<16|this._low;return t=t<<e|t>>>32-e,this._low=t&65535,this._high=t>>>16,this},t.prototype.rotateRight=t.prototype.rotr=function(e){var t=this._high<<16|this._low;return t=t>>>e|t<<32-e,this._low=t&65535,this._high=t>>>16,this},t.prototype.clone=function(){return new t(this._low,this._high)},typeof define!="undefined"&&define.amd?define([],function(){return t}):typeof n!="undefined"&&n.exports?n.exports=t:e.UINT32=t})(this)},cuint:function(e,t,n){t.UINT32=e("./lib/uint32"),t.UINT64=e("./lib/uint64")},xxhash:function(e,t,n){(function(t){function r(){if(arguments.length==2)return(new r(arguments[1])).update(arguments[0]).digest();if(!(this instanceof r))return new r(arguments[0]);i.call(this,arguments[0])}function i(e){return this.seed=e instanceof s?e.clone():s(e),this.v1=this.seed.clone().add(c),this.v2=this.seed.clone().add(u),this.v3=this.seed.clone(),this.v4=this.seed.clone().subtract(o),this.total_len=0,this.memsize=0,this.memory=null,this}var s=e("cuint").UINT32;s.prototype.xxh_update=function(e,t){var n=u._low,r=u._high,i,s;s=e*n,i=s>>>16,i+=t*n,i&=65535,i+=e*r;var a=this._low+(s&65535),f=a>>>16;f+=this._high+(i&65535);var l=f<<16|a&65535;l=l<<13|l>>>19,a=l&65535,f=l>>>16,n=o._low,r=o._high,s=a*n,i=s>>>16,i+=f*n,i&=65535,i+=a*r,this._low=s&65535,this._high=i&65535};var o=s("2654435761"),u=s("2246822519"),a=s("3266489917"),f=s("668265263"),l=s("374761393"),c=o.clone().add(u);r.prototype.init=i,r.prototype.update=function(e){var t=typeof e=="string",n=0,r=e.length,i=n+r;if(r==0)return this;this.total_len+=r,this.memsize==0&&(this.memory=t?"":new Buffer(16));if(this.memsize+r<16)return t?this.memory+=e:e.copy(this.memory,this.memsize,0,r),this.memsize+=r,this;if(this.memsize>0){t?this.memory+=e.slice(0,16-this.memsize):e.copy(this.memory,this.memsize,0,16-this.memsize);var s=0;t?(this.v1.xxh_update(this.memory.charCodeAt(s+1)<<8|this.memory.charCodeAt(s),this.memory.charCodeAt(s+3)<<8|this.memory.charCodeAt(s+2)),s+=4,this.v2.xxh_update(this.memory.charCodeAt(s+1)<<8|this.memory.charCodeAt(s),this.memory.charCodeAt(s+3)<<8|this.memory.charCodeAt(s+2)),s+=4,this.v3.xxh_update(this.memory.charCodeAt(s+1)<<8|this.memory.charCodeAt(s),this.memory.charCodeAt(s+3)<<8|this.memory.charCodeAt(s+2)),s+=4,this.v4.xxh_update(this.memory.charCodeAt(s+1)<<8|this.memory.charCodeAt(s),this.memory.charCodeAt(s+3)<<8|this.memory.charCodeAt(s+2))):(this.v1.xxh_update(this.memory[s+1]<<8|this.memory[s],this.memory[s+3]<<8|this.memory[s+2]),s+=4,this.v2.xxh_update(this.memory[s+1]<<8|this.memory[s],this.memory[s+3]<<8|this.memory[s+2]),s+=4,this.v3.xxh_update(this.memory[s+1]<<8|this.memory[s],this.memory[s+3]<<8|this.memory[s+2]),s+=4,this.v4.xxh_update(this.memory[s+1]<<8|this.memory[s],this.memory[s+3]<<8|this.memory[s+2])),n+=16-this.memsize,this.memsize=0,t&&(this.memory="")}if(n<=i-16){var o=i-16;do t?(this.v1.xxh_update(e.charCodeAt(n+1)<<8|e.charCodeAt(n),e.charCodeAt(n+3)<<8|e.charCodeAt(n+2)),n+=4,this.v2.xxh_update(e.charCodeAt(n+1)<<8|e.charCodeAt(n),e.charCodeAt(n+3)<<8|e.charCodeAt(n+2)),n+=4,this.v3.xxh_update(e.charCodeAt(n+1)<<8|e.charCodeAt(n),e.charCodeAt(n+3)<<8|e.charCodeAt(n+2)),n+=4,this.v4.xxh_update(e.charCodeAt(n+1)<<8|e.charCodeAt(n),e.charCodeAt(n+3)<<8|e.charCodeAt(n+2))):(this.v1.xxh_update(e[n+1]<<8|e[n],e[n+3]<<8|e[n+2]),n+=4,this.v2.xxh_update(e[n+1]<<8|e[n],e[n+3]<<8|e[n+2]),n+=4,this.v3.xxh_update(e[n+1]<<8|e[n],e[n+3]<<8|e[n+2]),n+=4,this.v4.xxh_update(e[n+1]<<8|e[n],e[n+3]<<8|e[n+2])),n+=4;while(n<=o)}return n<i&&(t?this.memory+=e.slice(n):e.copy(this.memory,this.memsize,n,i),this.memsize=i-n),this},r.prototype.digest=function(){var e=this.memory,t=typeof e=="string",n=0,r=this.memsize,i,c,h=new s;this.total_len>=16?i=this.v1.rotl(1).add(this.v2.rotl(7).add(this.v3.rotl(12).add(this.v4.rotl(18)))):i=this.seed.add(l),i.add(h.fromNumber(this.total_len));while(n<=r-4)t?h.fromBits(e.charCodeAt(n+1)<<8|e.charCodeAt(n),e.charCodeAt(n+3)<<8|e.charCodeAt(n+2)):h.fromBits(e[n+1]<<8|e[n],e[n+3]<<8|e[n+2]),i.add(h.multiply(a)).rotl(17).multiply(f),n+=4;while(n<r)h.fromBits(t?e.charCodeAt(n++):e[n++],0),i.add(h.multiply(l)).rotl(11).multiply(o);return c=i.clone().shiftRight(15),i.xor(c).multiply(u),c=i.clone().shiftRight(13),i.xor(c).multiply(a),c=i.clone().shiftRight(16),i.xor(c),this.init(this.seed),i},typeof define!="undefined"&&define.amd?define([],function(){return r}):typeof n!="undefined"&&n.exports?n.exports=r:t.XXH=r})(this)}},{},{})
(function(e,t,n,r,i){var s={},o=function(t){return e.Function("return "+t)()},u=e.document,a,f=function(t,i){var o={exports:{}};s[t]=1,n[t]=o.exports;if(!i)i=i||e[t];else if(typeof i=="function"){var u=l;r[t]&&r[t].sandbox&&typeof u=="function"&&(u=a),i=i(u,o.exports,o)||o.exports}return i=i,n[t]=i},l=function(e){var t=n[e],r=[e,t];return r&&(e=r[0],t=r[1]),s[e]&&t?t:(typeof t=="string"&&t.indexOf("(function(")===0&&(t=o(t)),f(e,t))},c={exports:{}};for(var h in n)s[h]=0;t(l,c.exports,c)})(this,function(e,t,n){window.XXH=e("xxhash")},{"./lib/uint32":function(e,t,n){(function(e){function t(e,n){if(!(this instanceof t))return new t(e,n);this._low=0,this._high=0,this.remainder=null;if(typeof n=="undefined")return i.call(this,e);if(typeof e=="string")return s.call(this,e,n);r.call(this,e,n)}function r(e,t){return this._low=e|0,this._high=t|0,this}function i(e){return this._low=e&65535,this._high=e>>>16,this}function s(e,t){var n=parseInt(e,t||10);return this._low=n&65535,this._high=n>>>16,this}var o={36:t(Math.pow(36,5)),16:t(Math.pow(16,7)),10:t(Math.pow(10,9)),2:t(Math.pow(2,30))},u={36:t(36),16:t(16),10:t(10),2:t(2)};t.prototype.fromBits=r,t.prototype.fromNumber=i,t.prototype.fromString=s,t.prototype.toNumber=function(){return this._high<<16|this._low},t.prototype.toString=function(e){e=e||10;var n=u[e]||new t(e);if(!this.gt(n))return this.toNumber().toString(e);var r=this.clone(),i=new Array(32);for(var s=31;s>=0;s--){r.div(n),i[s]=r.remainder.toNumber().toString(e);if(!r.gt(n))break}return i[s-1]=r.toNumber().toString(e),i.join("")},t.prototype.add=function(e){var t=this._low+e._low,n=t>>>16;return n+=this._high+e._high,this._low=t&65535,this._high=n&65535,this},t.prototype.subtract=function(e){return this.add(e.clone().negate())},t.prototype.multiply=function(e){var t=this._high,n=this._low,r=e._high,i=e._low,s,o;return o=n*i,s=o>>>16,s+=t*i,s&=65535,s+=n*r,this._low=o&65535,this._high=s&65535,this},t.prototype.div=function(e){if(e._low==0&&e._high==0)throw Error("division by zero");if(e._high==0&&e._low==1)return this.remainder=new t(0),this;if(e.gt(this))return this.remainder=new t(0),this._low=0,this._high=0,this;if(this.eq(e))return this.remainder=new t(0),this._low=1,this._high=0,this;var n=e.clone(),r=-1;while(!this.lt(n))n.shiftLeft(1,!0),r++;this.remainder=this.clone(),this._low=0,this._high=0;for(;r>=0;r--)n.shiftRight(1),this.remainder.lt(n)||(this.remainder.subtract(n),r>=16?this._high|=1<<r-16:this._low|=1<<r);return this},t.prototype.negate=t.prototype.not=function(){var e=(~this._low&65535)+1;return this._low=e&65535,this._high=~this._high+(e>>>16)&65535,this},t.prototype.equals=t.prototype.eq=function(e){return this._low==e._low&&this._high==e._high},t.prototype.greaterThan=t.prototype.gt=function(e){return this._high>e._high?!0:this._high<e._high?!1:this._low>e._low},t.prototype.lessThan=t.prototype.lt=function(e){return this._high<e._high?!0:this._high>e._high?!1:this._low<e._low},t.prototype.or=function(e){return this._low|=e._low,this._high|=e._high,this},t.prototype.and=function(e){return this._low&=e._low,this._high&=e._high,this},t.prototype.xor=function(e){return this._low^=e._low,this._high^=e._high,this},t.prototype.shiftRight=t.prototype.shiftr=function(e){return e>16?(this._low=this._high>>e-16,this._high=0):e==16?(this._low=this._high,this._high=0):(this._low=this._low>>e|this._high<<16-e&65535,this._high>>=e),this},t.prototype.shiftLeft=t.prototype.shiftl=function(e,t){return e>16?(this._high=this._low<<e-16,this._low=0,t||(this._high&=65535)):e==16?(this._high=this._low,this._low=0):(this._high=this._high<<e|this._low>>16-e,this._low=this._low<<e&65535,t||(this._high&=65535)),this},t.prototype.rotateLeft=t.prototype.rotl=function(e){var t=this._high<<16|this._low;return t=t<<e|t>>>32-e,this._low=t&65535,this._high=t>>>16,this},t.prototype.rotateRight=t.prototype.rotr=function(e){var t=this._high<<16|this._low;return t=t>>>e|t<<32-e,this._low=t&65535,this._high=t>>>16,this},t.prototype.clone=function(){return new t(this._low,this._high)},typeof define!="undefined"&&define.amd?define([],function(){return t}):typeof n!="undefined"&&n.exports?n.exports=t:e.UINT32=t})(this)},cuint:function(e,t,n){t.UINT32=e("./lib/uint32"),t.UINT64=e("./lib/uint64")},xxhash:function(e,t,n){(function(t){function r(){if(arguments.length==2)return(new r(arguments[1])).update(arguments[0]).digest();if(!(this instanceof r))return new r(arguments[0]);i.call(this,arguments[0])}function i(e){return this.seed=e instanceof s?e.clone():s(e),this.v1=this.seed.clone().add(c),this.v2=this.seed.clone().add(u),this.v3=this.seed.clone(),this.v4=this.seed.clone().subtract(o),this.total_len=0,this.memsize=0,this.memory=null,this}var s=e("cuint").UINT32;s.prototype.xxh_update=function(e,t){var n=u._low,r=u._high,i,s;s=e*n,i=s>>>16,i+=t*n,i&=65535,i+=e*r;var a=this._low+(s&65535),f=a>>>16;f+=this._high+(i&65535);var l=f<<16|a&65535;l=l<<13|l>>>19,a=l&65535,f=l>>>16,n=o._low,r=o._high,s=a*n,i=s>>>16,i+=f*n,i&=65535,i+=a*r,this._low=s&65535,this._high=i&65535};var o=s("2654435761"),u=s("2246822519"),a=s("3266489917"),f=s("668265263"),l=s("374761393"),c=o.clone().add(u);r.prototype.init=i,r.prototype.update=function(e){var t=typeof e=="string",n;e instanceof ArrayBuffer&&(n=!0,e=new Uint8Array(e));var r=0,i=e.length,s=r+i;if(i==0)return this;this.total_len+=i,this.memsize==0&&(t?this.memory="":n?this.memory=new Uint8Array(16):this.memory=new Buffer(16));if(this.memsize+i<16)return t?this.memory+=e:n?this.memory.set(e.subarray(0,i),this.memsize):e.copy(this.memory,this.memsize,0,i),this.memsize+=i,this;if(this.memsize>0){t?this.memory+=e.slice(0,16-this.memsize):n?this.memory.set(e.subarray(0,16-this.memsize),this.memsize):e.copy(this.memory,this.memsize,0,16-this.memsize);var o=0;t?(this.v1.xxh_update(this.memory.charCodeAt(o+1)<<8|this.memory.charCodeAt(o),this.memory.charCodeAt(o+3)<<8|this.memory.charCodeAt(o+2)),o+=4,this.v2.xxh_update(this.memory.charCodeAt(o+1)<<8|this.memory.charCodeAt(o),this.memory.charCodeAt(o+3)<<8|this.memory.charCodeAt(o+2)),o+=4,this.v3.xxh_update(this.memory.charCodeAt(o+1)<<8|this.memory.charCodeAt(o),this.memory.charCodeAt(o+3)<<8|this.memory.charCodeAt(o+2)),o+=4,this.v4.xxh_update(this.memory.charCodeAt(o+1)<<8|this.memory.charCodeAt(o),this.memory.charCodeAt(o+3)<<8|this.memory.charCodeAt(o+2))):(this.v1.xxh_update(this.memory[o+1]<<8|this.memory[o],this.memory[o+3]<<8|this.memory[o+2]),o+=4,this.v2.xxh_update(this.memory[o+1]<<8|this.memory[o],this.memory[o+3]<<8|this.memory[o+2]),o+=4,this.v3.xxh_update(this.memory[o+1]<<8|this.memory[o],this.memory[o+3]<<8|this.memory[o+2]),o+=4,this.v4.xxh_update(this.memory[o+1]<<8|this.memory[o],this.memory[o+3]<<8|this.memory[o+2])),r+=16-this.memsize,this.memsize=0,t&&(this.memory="")}if(r<=s-16){var u=s-16;do t?(this.v1.xxh_update(e.charCodeAt(r+1)<<8|e.charCodeAt(r),e.charCodeAt(r+3)<<8|e.charCodeAt(r+2)),r+=4,this.v2.xxh_update(e.charCodeAt(r+1)<<8|e.charCodeAt(r),e.charCodeAt(r+3)<<8|e.charCodeAt(r+2)),r+=4,this.v3.xxh_update(e.charCodeAt(r+1)<<8|e.charCodeAt(r),e.charCodeAt(r+3)<<8|e.charCodeAt(r+2)),r+=4,this.v4.xxh_update(e.charCodeAt(r+1)<<8|e.charCodeAt(r),e.charCodeAt(r+3)<<8|e.charCodeAt(r+2))):(this.v1.xxh_update(e[r+1]<<8|e[r],e[r+3]<<8|e[r+2]),r+=4,this.v2.xxh_update(e[r+1]<<8|e[r],e[r+3]<<8|e[r+2]),r+=4,this.v3.xxh_update(e[r+1]<<8|e[r],e[r+3]<<8|e[r+2]),r+=4,this.v4.xxh_update(e[r+1]<<8|e[r],e[r+3]<<8|e[r+2])),r+=4;while(r<=u)}return r<s&&(t?this.memory+=e.slice(r):n?this.memory.set(e.subarray(r,s),this.memsize):e.copy(this.memory,this.memsize,r,s),this.memsize=s-r),this},r.prototype.digest=function(){var e=this.memory,t=typeof e=="string",n=0,r=this.memsize,i,c,h=new s;this.total_len>=16?i=this.v1.rotl(1).add(this.v2.rotl(7).add(this.v3.rotl(12).add(this.v4.rotl(18)))):i=this.seed.add(l),i.add(h.fromNumber(this.total_len));while(n<=r-4)t?h.fromBits(e.charCodeAt(n+1)<<8|e.charCodeAt(n),e.charCodeAt(n+3)<<8|e.charCodeAt(n+2)):h.fromBits(e[n+1]<<8|e[n],e[n+3]<<8|e[n+2]),i.add(h.multiply(a)).rotl(17).multiply(f),n+=4;while(n<r)h.fromBits(t?e.charCodeAt(n++):e[n++],0),i.add(h.multiply(l)).rotl(11).multiply(o);return c=i.clone().shiftRight(15),i.xor(c).multiply(u),c=i.clone().shiftRight(13),i.xor(c).multiply(a),c=i.clone().shiftRight(16),i.xor(c),this.init(this.seed),i},typeof define!="undefined"&&define.amd?define([],function(){return r}):typeof n!="undefined"&&n.exports?n.exports=r:t.XXH=r})(this)}},{},{})

@@ -0,1 +1,6 @@

0.0.5 / 2014-05-19
==================
* Added ArrayBuffer support
0.0.4 / 2014-04-25

@@ -2,0 +7,0 @@ ==================

{
"name": "xxhashjs",
"version": "0.0.4",
"version": "0.0.5",
"description": "xxHash in Javascript",

@@ -5,0 +5,0 @@ "main": "xxhash.js",

@@ -45,3 +45,3 @@ # Javascript implementation of xxHash

`XXH(<data>, <seed>)`
The data can either be a string or a NodeJS Buffer object.
The data can either be a string, an ArrayBuffer or a NodeJS Buffer object.
The seed can either be a number or a UINT32 object.

@@ -69,3 +69,3 @@

* `XXH.update(<data>)`
Add data for hashing. The data can either be a string or a NodeJS Buffer object.
Add data for hashing. The data can either be a string, an ArrayBuffer or a NodeJS Buffer object.
* `XXH.digest()` (_UINT32_)

@@ -72,0 +72,0 @@ Finalize the hash calculations and returns an UINT32 object. The hash value can be retrived with toString(<radix>).

@@ -107,3 +107,3 @@ /**

* @method update
* @param {String|Buffer} input as a string or nodejs Buffer
* @param {String|Buffer|ArrayBuffer} input as a string or nodejs Buffer or ArrayBuffer
* @return ThisExpression

@@ -113,2 +113,10 @@ */

var isString = typeof input == 'string'
var isArrayBuffer
if (input instanceof ArrayBuffer)
{
isArrayBuffer = true
input = new Uint8Array(input);
}
var p = 0

@@ -122,3 +130,12 @@ var len = input.length

if (this.memsize == 0) this.memory = isString ? '' : new Buffer(16)
if (this.memsize == 0)
{
if (isString) {
this.memory = ''
} else if (isArrayBuffer) {
this.memory = new Uint8Array(16)
} else {
this.memory = new Buffer(16)
}
}

@@ -130,2 +147,4 @@ if (this.memsize + len < 16) // fill in tmp buffer

this.memory += input
} else if (isArrayBuffer) {
this.memory.set( input.subarray(0, len), this.memsize )
} else {

@@ -144,2 +163,4 @@ input.copy( this.memory, this.memsize, 0, len )

this.memory += input.slice(0, 16 - this.memsize)
} else if (isArrayBuffer) {
this.memory.set( input.subarray(0, 16 - this.memsize), this.memsize )
} else {

@@ -253,2 +274,4 @@ input.copy( this.memory, this.memsize, 0, 16 - this.memsize )

this.memory += input.slice(p)
} else if (isArrayBuffer) {
this.memory.set( input.subarray(p, bEnd), this.memsize )
} else {

@@ -345,2 +368,2 @@ input.copy( this.memory, this.memsize, p, bEnd )

})(this)
})(this)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc