js-binarypack
Advanced tools
Comparing version 0.0.1 to 0.0.4
@@ -15,5 +15,7 @@ /** | ||
var template = '/*! binarypack.%ext% build:' + package.version + ', %type%. Copyright(c) 2012 Eric Zhang <eric@ericzhang.com> MIT Licensed */\n' | ||
var template = '/*! binarypack.%ext% build:' + package.version + ', %type%. Copyright(c) 2012 Eric Zhang <eric@ericzhang.com> MIT Licensed */' | ||
, prefix = '\n(function(exports){\n' | ||
, development = template.replace('%type%', 'development').replace('%ext%', 'js') | ||
, production = template.replace('%type%', 'production').replace('%ext%', 'min.js'); | ||
, production = template.replace('%type%', 'production').replace('%ext%', 'min.js') | ||
, suffix = '\n})(this);\n'; | ||
@@ -111,2 +113,4 @@ /** | ||
, ignore = 0; | ||
code += prefix; | ||
@@ -149,2 +153,4 @@ files.forEach(function (file) { | ||
code += suffix; | ||
// check if we need to process it any further | ||
@@ -151,0 +157,0 @@ if (settings.minify) { |
@@ -1,21 +0,38 @@ | ||
/*! binarypack.js build:0.0.0, development. Copyright(c) 2012 Eric Zhang <eric@ericzhang.com> MIT Licensed */ | ||
var binaryFeatures = { | ||
useBlobBuilder: (function(){ | ||
try { | ||
new Blob([]); | ||
/*! binarypack.js build:0.0.4, development. Copyright(c) 2012 Eric Zhang <eric@ericzhang.com> MIT Licensed */ | ||
(function(exports){ | ||
var binaryFeatures = {}; | ||
binaryFeatures.useBlobBuilder = (function(){ | ||
try { | ||
new Blob([]); | ||
return false; | ||
} catch (e) { | ||
return true; | ||
} | ||
})(); | ||
binaryFeatures.useArrayBufferView = !binaryFeatures.useBlobBuilder && (function(){ | ||
try { | ||
return (new Blob([new Uint8Array([])])).size === 0; | ||
} catch (e) { | ||
return true; | ||
} | ||
})(); | ||
binaryFeatures.supportsBinaryWebsockets = (function(){ | ||
try { | ||
var wstest = new WebSocket('ws://null'); | ||
wstest.onerror = function(){}; | ||
if (typeof(wstest.binaryType) !== "undefined") { | ||
return true; | ||
} else { | ||
return false; | ||
} catch (e) { | ||
return true; | ||
} | ||
})(), | ||
useArrayBufferView: (function(){ | ||
try { | ||
return (new Blob([new Uint8Array([])])).size === 0; | ||
} catch (e) { | ||
return true; | ||
} | ||
})() | ||
}; | ||
wstest.close(); | ||
wstest = null; | ||
} catch (e) { | ||
return false; | ||
} | ||
})(); | ||
var BlobBuilder = window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder || window.BlobBuilder; | ||
exports.binaryFeatures = binaryFeatures; | ||
exports.BlobBuilder = window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder || window.BlobBuilder; | ||
@@ -59,9 +76,9 @@ function BufferBuilder(){ | ||
}; | ||
BinaryPack = { | ||
exports.BinaryPack = { | ||
unpack: function(data){ | ||
var unpacker = new BinaryPack.Unpacker(data); | ||
var unpacker = new Unpacker(data); | ||
return unpacker.unpack(); | ||
}, | ||
pack: function(data){ | ||
var packer = new BinaryPack.Packer(); | ||
var packer = new Packer(); | ||
var buffer = packer.pack(data); | ||
@@ -72,3 +89,3 @@ return buffer; | ||
BinaryPack.Unpacker = function(data){ | ||
function Unpacker (data){ | ||
// Data is ArrayBuffer | ||
@@ -82,3 +99,3 @@ this.index = 0; | ||
BinaryPack.Unpacker.prototype.unpack = function(){ | ||
Unpacker.prototype.unpack = function(){ | ||
var type = this.unpack_uint8(); | ||
@@ -166,3 +183,3 @@ if (type < 0x80){ | ||
BinaryPack.Unpacker.prototype.unpack_uint8 = function(){ | ||
Unpacker.prototype.unpack_uint8 = function(){ | ||
var byte = this.dataView[this.index] & 0xff; | ||
@@ -173,3 +190,3 @@ this.index++; | ||
BinaryPack.Unpacker.prototype.unpack_uint16 = function(){ | ||
Unpacker.prototype.unpack_uint16 = function(){ | ||
var bytes = this.read(2); | ||
@@ -182,3 +199,3 @@ var uint16 = | ||
BinaryPack.Unpacker.prototype.unpack_uint32 = function(){ | ||
Unpacker.prototype.unpack_uint32 = function(){ | ||
var bytes = this.read(4); | ||
@@ -194,3 +211,3 @@ var uint32 = | ||
BinaryPack.Unpacker.prototype.unpack_uint64 = function(){ | ||
Unpacker.prototype.unpack_uint64 = function(){ | ||
var bytes = this.read(8); | ||
@@ -211,3 +228,3 @@ var uint64 = | ||
BinaryPack.Unpacker.prototype.unpack_int8 = function(){ | ||
Unpacker.prototype.unpack_int8 = function(){ | ||
var uint8 = this.unpack_uint8(); | ||
@@ -217,3 +234,3 @@ return (uint8 < 0x80 ) ? uint8 : uint8 - (1 << 8); | ||
BinaryPack.Unpacker.prototype.unpack_int16 = function(){ | ||
Unpacker.prototype.unpack_int16 = function(){ | ||
var uint16 = this.unpack_uint16(); | ||
@@ -223,3 +240,3 @@ return (uint16 < 0x8000 ) ? uint16 : uint16 - (1 << 16); | ||
BinaryPack.Unpacker.prototype.unpack_int32 = function(){ | ||
Unpacker.prototype.unpack_int32 = function(){ | ||
var uint32 = this.unpack_uint32(); | ||
@@ -230,3 +247,3 @@ return (uint32 < Math.pow(2, 31) ) ? uint32 : | ||
BinaryPack.Unpacker.prototype.unpack_int64 = function(){ | ||
Unpacker.prototype.unpack_int64 = function(){ | ||
var uint64 = this.unpack_uint64(); | ||
@@ -237,3 +254,3 @@ return (uint64 < Math.pow(2, 63) ) ? uint64 : | ||
BinaryPack.Unpacker.prototype.unpack_raw = function(size){ | ||
Unpacker.prototype.unpack_raw = function(size){ | ||
if ( this.length < this.index + size){ | ||
@@ -251,3 +268,3 @@ throw new Error('BinaryPackFailure: index is out of range' | ||
BinaryPack.Unpacker.prototype.unpack_string = function(size){ | ||
Unpacker.prototype.unpack_string = function(size){ | ||
var bytes = this.read(size); | ||
@@ -275,3 +292,3 @@ var i = 0, str = '', c, code; | ||
BinaryPack.Unpacker.prototype.unpack_array = function(size){ | ||
Unpacker.prototype.unpack_array = function(size){ | ||
var objects = new Array(size); | ||
@@ -284,3 +301,3 @@ for(var i = 0; i < size ; i++){ | ||
BinaryPack.Unpacker.prototype.unpack_map = function(size){ | ||
Unpacker.prototype.unpack_map = function(size){ | ||
var map = {}; | ||
@@ -295,3 +312,3 @@ for(var i = 0; i < size ; i++){ | ||
BinaryPack.Unpacker.prototype.unpack_float = function(){ | ||
Unpacker.prototype.unpack_float = function(){ | ||
var uint32 = this.unpack_uint32(); | ||
@@ -305,3 +322,3 @@ var sign = uint32 >> 31; | ||
BinaryPack.Unpacker.prototype.unpack_double = function(){ | ||
Unpacker.prototype.unpack_double = function(){ | ||
var h32 = this.unpack_uint32(); | ||
@@ -317,3 +334,3 @@ var l32 = this.unpack_uint32(); | ||
BinaryPack.Unpacker.prototype.read = function(length){ | ||
Unpacker.prototype.read = function(length){ | ||
var j = this.index; | ||
@@ -327,7 +344,7 @@ if (j + length <= this.length) { | ||
BinaryPack.Packer = function(){ | ||
function Packer (){ | ||
this.bufferBuilder = new BufferBuilder(); | ||
} | ||
BinaryPack.Packer.prototype.pack = function(value){ | ||
Packer.prototype.pack = function(value){ | ||
var type = typeof(value); | ||
@@ -357,2 +374,4 @@ if (type == 'string'){ | ||
this.pack_array(value); | ||
} else if (constructor == Blob || constructor == File) { | ||
this.pack_bin(value); | ||
} else if (constructor == ArrayBuffer) { | ||
@@ -364,3 +383,3 @@ if(binaryFeatures.useArrayBufferView) { | ||
} | ||
} else if (Uint8Array.prototype.__proto__.isPrototypeOf(value) || constructor == Blob){ | ||
} else if ('BYTES_PER_ELEMENT' in value){ | ||
if(binaryFeatures.useArrayBufferView) { | ||
@@ -388,5 +407,5 @@ this.pack_bin(value); | ||
BinaryPack.Packer.prototype.pack_bin = function(blob){ | ||
Packer.prototype.pack_bin = function(blob){ | ||
var length = blob.length || blob.byteLength || blob.size; | ||
if (length <= 0x1f){ | ||
if (length <= 0x0f){ | ||
this.pack_uint8(0xa0 + length); | ||
@@ -406,5 +425,5 @@ } else if (length <= 0xffff){ | ||
BinaryPack.Packer.prototype.pack_string = function(str){ | ||
Packer.prototype.pack_string = function(str){ | ||
var length = str.length; | ||
if (length <= 0x1f){ | ||
if (length <= 0x0f){ | ||
this.pack_uint8(0xb0 + length); | ||
@@ -424,3 +443,3 @@ } else if (length <= 0xffff){ | ||
BinaryPack.Packer.prototype.pack_array = function(ary){ | ||
Packer.prototype.pack_array = function(ary){ | ||
var length = ary.length; | ||
@@ -443,3 +462,3 @@ if (length <= 0x0f){ | ||
BinaryPack.Packer.prototype.pack_integer = function(num){ | ||
Packer.prototype.pack_integer = function(num){ | ||
if ( -0x20 <= num && num <= 0x7f){ | ||
@@ -476,3 +495,3 @@ this.bufferBuilder.append(num & 0xff); | ||
BinaryPack.Packer.prototype.pack_double = function(num){ | ||
Packer.prototype.pack_double = function(num){ | ||
var sign = 0; | ||
@@ -495,3 +514,3 @@ if (num < 0){ | ||
BinaryPack.Packer.prototype.pack_object = function(obj){ | ||
Packer.prototype.pack_object = function(obj){ | ||
var keys = Object.keys(obj); | ||
@@ -518,7 +537,7 @@ var length = keys.length; | ||
BinaryPack.Packer.prototype.pack_uint8 = function(num){ | ||
Packer.prototype.pack_uint8 = function(num){ | ||
this.bufferBuilder.append(num); | ||
} | ||
BinaryPack.Packer.prototype.pack_uint16 = function(num){ | ||
Packer.prototype.pack_uint16 = function(num){ | ||
this.bufferBuilder.append(num >> 8); | ||
@@ -528,3 +547,3 @@ this.bufferBuilder.append(num & 0xff); | ||
BinaryPack.Packer.prototype.pack_uint32 = function(num){ | ||
Packer.prototype.pack_uint32 = function(num){ | ||
var n = num & 0xffffffff; | ||
@@ -537,3 +556,3 @@ this.bufferBuilder.append((n & 0xff000000) >>> 24); | ||
BinaryPack.Packer.prototype.pack_uint64 = function(num){ | ||
Packer.prototype.pack_uint64 = function(num){ | ||
var high = num / Math.pow(2, 32); | ||
@@ -551,7 +570,7 @@ var low = num % Math.pow(2, 32); | ||
BinaryPack.Packer.prototype.pack_int8 = function(num){ | ||
Packer.prototype.pack_int8 = function(num){ | ||
this.bufferBuilder.append(num & 0xff); | ||
} | ||
BinaryPack.Packer.prototype.pack_int16 = function(num){ | ||
Packer.prototype.pack_int16 = function(num){ | ||
this.bufferBuilder.append((num & 0xff00) >> 8); | ||
@@ -561,3 +580,3 @@ this.bufferBuilder.append(num & 0xff); | ||
BinaryPack.Packer.prototype.pack_int32 = function(num){ | ||
Packer.prototype.pack_int32 = function(num){ | ||
this.bufferBuilder.append((num >>> 24) & 0xff); | ||
@@ -569,3 +588,3 @@ this.bufferBuilder.append((num & 0x00ff0000) >>> 16); | ||
BinaryPack.Packer.prototype.pack_int64 = function(num){ | ||
Packer.prototype.pack_int64 = function(num){ | ||
var high = Math.floor(num / Math.pow(2, 32)); | ||
@@ -582,1 +601,3 @@ var low = num % Math.pow(2, 32); | ||
} | ||
})(this); |
@@ -1,2 +0,1 @@ | ||
/*! binarypack.min.js build:0.0.0, production. Copyright(c) 2012 Eric Zhang <eric@ericzhang.com> MIT Licensed */ | ||
function BufferBuilder(){this._pieces=[],this._parts=[]}var binaryFeatures={useBlobBuilder:function(){try{return new Blob([]),!1}catch(e){return!0}}(),useArrayBufferView:function(){try{return(new Blob([new Uint8Array([])])).size===0}catch(e){return!0}}()},BlobBuilder=window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder||window.BlobBuilder;BufferBuilder.prototype.append=function(e){typeof e=="number"?this._pieces.push(e):(this._flush(),this._parts.push(e))},BufferBuilder.prototype._flush=function(){if(this._pieces.length>0){var e=new Uint8Array(this._pieces);binaryFeatures.useArrayBufferView||(e=e.buffer),this._parts.push(e),this._pieces=[]}},BufferBuilder.prototype.getBuffer=function(){this._flush();if(binaryFeatures.useBlobBuilder){var e=new BlobBuilder;for(var t=0,n=this._parts.length;t<n;t++)e.append(this._parts[t]);return e.getBlob()}return new Blob(this._parts)},BinaryPack={unpack:function(e){var t=new BinaryPack.Unpacker(e);return t.unpack()},pack:function(e){var t=new BinaryPack.Packer,n=t.pack(e);return n}},BinaryPack.Unpacker=function(e){this.index=0,this.dataBuffer=e,this.dataView=new Uint8Array(this.dataBuffer),this.length=this.dataBuffer.byteLength},BinaryPack.Unpacker.prototype.unpack=function(){var e=this.unpack_uint8();if(e<128){var t=e;return t}if((e^224)<32){var n=(e^224)-32;return n}var r;if((r=e^160)<=15)return this.unpack_raw(r);if((r=e^176)<=15)return this.unpack_string(r);if((r=e^144)<=15)return this.unpack_array(r);if((r=e^128)<=15)return this.unpack_map(r);switch(e){case 192:return null;case 193:return undefined;case 194:return!1;case 195:return!0;case 202:return this.unpack_float();case 203:return this.unpack_double();case 204:return this.unpack_uint8();case 205:return this.unpack_uint16();case 206:return this.unpack_uint32();case 207:return this.unpack_uint64();case 208:return this.unpack_int8();case 209:return this.unpack_int16();case 210:return this.unpack_int32();case 211:return this.unpack_int64();case 212:return undefined;case 213:return undefined;case 214:return undefined;case 215:return undefined;case 216:return r=this.unpack_uint16(),this.unpack_string(r);case 217:return r=this.unpack_uint32(),this.unpack_string(r);case 218:return r=this.unpack_uint16(),this.unpack_raw(r);case 219:return r=this.unpack_uint32(),this.unpack_raw(r);case 220:return r=this.unpack_uint16(),this.unpack_array(r);case 221:return r=this.unpack_uint32(),this.unpack_array(r);case 222:return r=this.unpack_uint16(),this.unpack_map(r);case 223:return r=this.unpack_uint32(),this.unpack_map(r)}},BinaryPack.Unpacker.prototype.unpack_uint8=function(){var e=this.dataView[this.index]&255;return this.index++,e},BinaryPack.Unpacker.prototype.unpack_uint16=function(){var e=this.read(2),t=(e[0]&255)*256+(e[1]&255);return this.index+=2,t},BinaryPack.Unpacker.prototype.unpack_uint32=function(){var e=this.read(4),t=((e[0]*256+e[1])*256+e[2])*256+e[3];return this.index+=4,t},BinaryPack.Unpacker.prototype.unpack_uint64=function(){var e=this.read(8),t=((((((e[0]*256+e[1])*256+e[2])*256+e[3])*256+e[4])*256+e[5])*256+e[6])*256+e[7];return this.index+=8,t},BinaryPack.Unpacker.prototype.unpack_int8=function(){var e=this.unpack_uint8();return e<128?e:e-256},BinaryPack.Unpacker.prototype.unpack_int16=function(){var e=this.unpack_uint16();return e<32768?e:e-65536},BinaryPack.Unpacker.prototype.unpack_int32=function(){var e=this.unpack_uint32();return e<Math.pow(2,31)?e:e-Math.pow(2,32)},BinaryPack.Unpacker.prototype.unpack_int64=function(){var e=this.unpack_uint64();return e<Math.pow(2,63)?e:e-Math.pow(2,64)},BinaryPack.Unpacker.prototype.unpack_raw=function(e){if(this.length<this.index+e)throw new Error("BinaryPackFailure: index is out of range "+this.index+" "+e+" "+this.length);var t=this.dataBuffer.slice(this.index,this.index+e);return this.index+=e,t},BinaryPack.Unpacker.prototype.unpack_string=function(e){var t=this.read(e),n=0,r="",i,s;while(n<e)i=t[n],i<128?(r+=String.fromCharCode(i),n++):(i^192)<32?(s=(i^192)<<6|t[n+1]&63,r+=String.fromCharCode(s),n+=2):(s=(i&15)<<12|(t[n+1]&63)<<6|t[n+2]&63,r+=String.fromCharCode(s),n+=3);return this.index+=e,r},BinaryPack.Unpacker.prototype.unpack_array=function(e){var t=new Array(e);for(var n=0;n<e;n++)t[n]=this.unpack();return t},BinaryPack.Unpacker.prototype.unpack_map=function(e){var t={};for(var n=0;n<e;n++){var r=this.unpack(),i=this.unpack();t[r]=i}return t},BinaryPack.Unpacker.prototype.unpack_float=function(){var e=this.unpack_uint32(),t=e>>31,n=(e>>23&255)-127,r=e&8388607|8388608;return(t==0?1:-1)*r*Math.pow(2,n-23)},BinaryPack.Unpacker.prototype.unpack_double=function(){var e=this.unpack_uint32(),t=this.unpack_uint32(),n=e>>31,r=(e>>20&2047)-1023,i=e&1048575|1048576,s=i*Math.pow(2,r-20)+t*Math.pow(2,r-52);return(n==0?1:-1)*s},BinaryPack.Unpacker.prototype.read=function(e){var t=this.index;if(t+e<=this.length)return this.dataView.subarray(t,t+e);throw new Error("BinaryPackFailure: read index out of range")},BinaryPack.Packer=function(){this.bufferBuilder=new BufferBuilder},BinaryPack.Packer.prototype.pack=function(e){var t=typeof e;if(t=="string")this.pack_string(e);else if(t=="number")Math.floor(e)===e?this.pack_integer(e):this.pack_double(e);else if(t=="boolean")e===!0?this.bufferBuilder.append(195):e===!1&&this.bufferBuilder.append(194);else if(t=="undefined")this.bufferBuilder.append(192);else{if(t!="object")throw new Error('Type "'+t+'" not yet supported');if(e===null)this.bufferBuilder.append(192);else{var n=e.constructor;if(n==Array)this.pack_array(e);else if(n==ArrayBuffer)binaryFeatures.useArrayBufferView?this.pack_bin(new Uint8Array(e)):this.pack_bin(e);else if(Uint8Array.prototype.__proto__.isPrototypeOf(e)||n==Blob)binaryFeatures.useArrayBufferView?this.pack_bin(e):this.pack_bin(e.buffer);else if(n==Object)this.pack_object(e);else if(n==Date)this.pack_string(e.toString());else{if(typeof e.toBinaryPack!="function")throw new Error('Type "'+n.toString()+'" not yet supported');this.bufferBuilder.append(e.toBinaryPack())}}}return this.bufferBuilder.getBuffer()},BinaryPack.Packer.prototype.pack_bin=function(e){var t=e.length||e.byteLength||e.size;if(t<=31)this.pack_uint8(160+t);else if(t<=65535)this.bufferBuilder.append(218),this.pack_uint16(t);else{if(!(t<=4294967295))throw new Error("Invalid length");this.bufferBuilder.append(219),this.pack_uint32(t)}this.bufferBuilder.append(e)},BinaryPack.Packer.prototype.pack_string=function(e){var t=e.length;if(t<=31)this.pack_uint8(176+t);else if(t<=65535)this.bufferBuilder.append(216),this.pack_uint16(t);else{if(!(t<=4294967295))throw new Error("Invalid length");this.bufferBuilder.append(217),this.pack_uint32(t)}this.bufferBuilder.append(e)},BinaryPack.Packer.prototype.pack_array=function(e){var t=e.length;if(t<=15)this.pack_uint8(144+t);else if(t<=65535)this.bufferBuilder.append(220),this.pack_uint16(t);else{if(!(t<=4294967295))throw new Error("Invalid length");this.bufferBuilder.append(221),this.pack_uint32(t)}for(var n=0;n<t;n++)this.pack(e[n])},BinaryPack.Packer.prototype.pack_integer=function(e){if(-32<=e&&e<=127)this.bufferBuilder.append(e&255);else if(0<=e&&e<=255)this.bufferBuilder.append(204),this.pack_uint8(e);else if(-128<=e&&e<=127)this.bufferBuilder.append(208),this.pack_int8(e);else if(0<=e&&e<=65535)this.bufferBuilder.append(205),this.pack_uint16(e);else if(-32768<=e&&e<=32767)this.bufferBuilder.append(209),this.pack_int16(e);else if(0<=e&&e<=4294967295)this.bufferBuilder.append(206),this.pack_uint32(e);else if(-2147483648<=e&&e<=2147483647)this.bufferBuilder.append(210),this.pack_int32(e);else if(-0x8000000000000000<=e&&e<=0x8000000000000000)this.bufferBuilder.append(211),this.pack_int64(e);else{if(!(0<=e&&e<=0x10000000000000000))throw new Error("Invalid integer");this.bufferBuilder.append(207),this.pack_uint64(e)}},BinaryPack.Packer.prototype.pack_double=function(e){var t=0;e<0&&(t=1,e=-e);var n=Math.floor(Math.log(e)/Math.LN2),r=e/Math.pow(2,n)-1,i=Math.floor(r*Math.pow(2,52)),s=Math.pow(2,32),o=t<<31|n+1023<<20|i/s&1048575,u=i%s;this.bufferBuilder.append(203),this.pack_int32(o),this.pack_int32(u)},BinaryPack.Packer.prototype.pack_object=function(e){var t=Object.keys(e),n=t.length;if(n<=15)this.pack_uint8(128+n);else if(n<=65535)this.bufferBuilder.append(222),this.pack_uint16(n);else{if(!(n<=4294967295))throw new Error("Invalid length");this.bufferBuilder.append(223),this.pack_uint32(n)}for(var r in e)e.hasOwnProperty(r)&&(this.pack(r),this.pack(e[r]))},BinaryPack.Packer.prototype.pack_uint8=function(e){this.bufferBuilder.append(e)},BinaryPack.Packer.prototype.pack_uint16=function(e){this.bufferBuilder.append(e>>8),this.bufferBuilder.append(e&255)},BinaryPack.Packer.prototype.pack_uint32=function(e){var t=e&4294967295;this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255)},BinaryPack.Packer.prototype.pack_uint64=function(e){var t=e/Math.pow(2,32),n=e%Math.pow(2,32);this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255),this.bufferBuilder.append((n&4278190080)>>>24),this.bufferBuilder.append((n&16711680)>>>16),this.bufferBuilder.append((n&65280)>>>8),this.bufferBuilder.append(n&255)},BinaryPack.Packer.prototype.pack_int8=function(e){this.bufferBuilder.append(e&255)},BinaryPack.Packer.prototype.pack_int16=function(e){this.bufferBuilder.append((e&65280)>>8),this.bufferBuilder.append(e&255)},BinaryPack.Packer.prototype.pack_int32=function(e){this.bufferBuilder.append(e>>>24&255),this.bufferBuilder.append((e&16711680)>>>16),this.bufferBuilder.append((e&65280)>>>8),this.bufferBuilder.append(e&255)},BinaryPack.Packer.prototype.pack_int64=function(e){var t=Math.floor(e/Math.pow(2,32)),n=e%Math.pow(2,32);this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255),this.bufferBuilder.append((n&4278190080)>>>24),this.bufferBuilder.append((n&16711680)>>>16),this.bufferBuilder.append((n&65280)>>>8),this.bufferBuilder.append(n&255)} | ||
/*! binarypack.min.js build:0.0.4, production. Copyright(c) 2012 Eric Zhang <eric@ericzhang.com> MIT Licensed */(function(e){function n(){this._pieces=[],this._parts=[]}function r(e){this.index=0,this.dataBuffer=e,this.dataView=new Uint8Array(this.dataBuffer),this.length=this.dataBuffer.byteLength}function i(){this.bufferBuilder=new n}var t={};t.useBlobBuilder=function(){try{return new Blob([]),!1}catch(e){return!0}}(),t.useArrayBufferView=!t.useBlobBuilder&&function(){try{return(new Blob([new Uint8Array([])])).size===0}catch(e){return!0}}(),t.supportsBinaryWebsockets=function(){try{var e=new WebSocket("ws://null");return e.onerror=function(){},typeof e.binaryType!="undefined"?!0:!1}catch(t){return!1}}(),e.binaryFeatures=t,e.BlobBuilder=window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder||window.BlobBuilder,n.prototype.append=function(e){typeof e=="number"?this._pieces.push(e):(this._flush(),this._parts.push(e))},n.prototype._flush=function(){if(this._pieces.length>0){var e=new Uint8Array(this._pieces);t.useArrayBufferView||(e=e.buffer),this._parts.push(e),this._pieces=[]}},n.prototype.getBuffer=function(){this._flush();if(t.useBlobBuilder){var e=new BlobBuilder;for(var n=0,r=this._parts.length;n<r;n++)e.append(this._parts[n]);return e.getBlob()}return new Blob(this._parts)},e.BinaryPack={unpack:function(e){var t=new r(e);return t.unpack()},pack:function(e){var t=new i,n=t.pack(e);return n}},r.prototype.unpack=function(){var e=this.unpack_uint8();if(e<128){var t=e;return t}if((e^224)<32){var n=(e^224)-32;return n}var r;if((r=e^160)<=15)return this.unpack_raw(r);if((r=e^176)<=15)return this.unpack_string(r);if((r=e^144)<=15)return this.unpack_array(r);if((r=e^128)<=15)return this.unpack_map(r);switch(e){case 192:return null;case 193:return undefined;case 194:return!1;case 195:return!0;case 202:return this.unpack_float();case 203:return this.unpack_double();case 204:return this.unpack_uint8();case 205:return this.unpack_uint16();case 206:return this.unpack_uint32();case 207:return this.unpack_uint64();case 208:return this.unpack_int8();case 209:return this.unpack_int16();case 210:return this.unpack_int32();case 211:return this.unpack_int64();case 212:return undefined;case 213:return undefined;case 214:return undefined;case 215:return undefined;case 216:return r=this.unpack_uint16(),this.unpack_string(r);case 217:return r=this.unpack_uint32(),this.unpack_string(r);case 218:return r=this.unpack_uint16(),this.unpack_raw(r);case 219:return r=this.unpack_uint32(),this.unpack_raw(r);case 220:return r=this.unpack_uint16(),this.unpack_array(r);case 221:return r=this.unpack_uint32(),this.unpack_array(r);case 222:return r=this.unpack_uint16(),this.unpack_map(r);case 223:return r=this.unpack_uint32(),this.unpack_map(r)}},r.prototype.unpack_uint8=function(){var e=this.dataView[this.index]&255;return this.index++,e},r.prototype.unpack_uint16=function(){var e=this.read(2),t=(e[0]&255)*256+(e[1]&255);return this.index+=2,t},r.prototype.unpack_uint32=function(){var e=this.read(4),t=((e[0]*256+e[1])*256+e[2])*256+e[3];return this.index+=4,t},r.prototype.unpack_uint64=function(){var e=this.read(8),t=((((((e[0]*256+e[1])*256+e[2])*256+e[3])*256+e[4])*256+e[5])*256+e[6])*256+e[7];return this.index+=8,t},r.prototype.unpack_int8=function(){var e=this.unpack_uint8();return e<128?e:e-256},r.prototype.unpack_int16=function(){var e=this.unpack_uint16();return e<32768?e:e-65536},r.prototype.unpack_int32=function(){var e=this.unpack_uint32();return e<Math.pow(2,31)?e:e-Math.pow(2,32)},r.prototype.unpack_int64=function(){var e=this.unpack_uint64();return e<Math.pow(2,63)?e:e-Math.pow(2,64)},r.prototype.unpack_raw=function(e){if(this.length<this.index+e)throw new Error("BinaryPackFailure: index is out of range "+this.index+" "+e+" "+this.length);var t=this.dataBuffer.slice(this.index,this.index+e);return this.index+=e,t},r.prototype.unpack_string=function(e){var t=this.read(e),n=0,r="",i,s;while(n<e)i=t[n],i<128?(r+=String.fromCharCode(i),n++):(i^192)<32?(s=(i^192)<<6|t[n+1]&63,r+=String.fromCharCode(s),n+=2):(s=(i&15)<<12|(t[n+1]&63)<<6|t[n+2]&63,r+=String.fromCharCode(s),n+=3);return this.index+=e,r},r.prototype.unpack_array=function(e){var t=new Array(e);for(var n=0;n<e;n++)t[n]=this.unpack();return t},r.prototype.unpack_map=function(e){var t={};for(var n=0;n<e;n++){var r=this.unpack(),i=this.unpack();t[r]=i}return t},r.prototype.unpack_float=function(){var e=this.unpack_uint32(),t=e>>31,n=(e>>23&255)-127,r=e&8388607|8388608;return(t==0?1:-1)*r*Math.pow(2,n-23)},r.prototype.unpack_double=function(){var e=this.unpack_uint32(),t=this.unpack_uint32(),n=e>>31,r=(e>>20&2047)-1023,i=e&1048575|1048576,s=i*Math.pow(2,r-20)+t*Math.pow(2,r-52);return(n==0?1:-1)*s},r.prototype.read=function(e){var t=this.index;if(t+e<=this.length)return this.dataView.subarray(t,t+e);throw new Error("BinaryPackFailure: read index out of range")},i.prototype.pack=function(e){var n=typeof e;if(n=="string")this.pack_string(e);else if(n=="number")Math.floor(e)===e?this.pack_integer(e):this.pack_double(e);else if(n=="boolean")e===!0?this.bufferBuilder.append(195):e===!1&&this.bufferBuilder.append(194);else if(n=="undefined")this.bufferBuilder.append(192);else{if(n!="object")throw new Error('Type "'+n+'" not yet supported');if(e===null)this.bufferBuilder.append(192);else{var r=e.constructor;if(r==Array)this.pack_array(e);else if(r==Blob||r==File)this.pack_bin(e);else if(r==ArrayBuffer)t.useArrayBufferView?this.pack_bin(new Uint8Array(e)):this.pack_bin(e);else if("BYTES_PER_ELEMENT"in e)t.useArrayBufferView?this.pack_bin(e):this.pack_bin(e.buffer);else if(r==Object)this.pack_object(e);else if(r==Date)this.pack_string(e.toString());else{if(typeof e.toBinaryPack!="function")throw new Error('Type "'+r.toString()+'" not yet supported');this.bufferBuilder.append(e.toBinaryPack())}}}return this.bufferBuilder.getBuffer()},i.prototype.pack_bin=function(e){var t=e.length||e.byteLength||e.size;if(t<=15)this.pack_uint8(160+t);else if(t<=65535)this.bufferBuilder.append(218),this.pack_uint16(t);else{if(!(t<=4294967295))throw new Error("Invalid length");this.bufferBuilder.append(219),this.pack_uint32(t)}this.bufferBuilder.append(e)},i.prototype.pack_string=function(e){var t=e.length;if(t<=15)this.pack_uint8(176+t);else if(t<=65535)this.bufferBuilder.append(216),this.pack_uint16(t);else{if(!(t<=4294967295))throw new Error("Invalid length");this.bufferBuilder.append(217),this.pack_uint32(t)}this.bufferBuilder.append(e)},i.prototype.pack_array=function(e){var t=e.length;if(t<=15)this.pack_uint8(144+t);else if(t<=65535)this.bufferBuilder.append(220),this.pack_uint16(t);else{if(!(t<=4294967295))throw new Error("Invalid length");this.bufferBuilder.append(221),this.pack_uint32(t)}for(var n=0;n<t;n++)this.pack(e[n])},i.prototype.pack_integer=function(e){if(-32<=e&&e<=127)this.bufferBuilder.append(e&255);else if(0<=e&&e<=255)this.bufferBuilder.append(204),this.pack_uint8(e);else if(-128<=e&&e<=127)this.bufferBuilder.append(208),this.pack_int8(e);else if(0<=e&&e<=65535)this.bufferBuilder.append(205),this.pack_uint16(e);else if(-32768<=e&&e<=32767)this.bufferBuilder.append(209),this.pack_int16(e);else if(0<=e&&e<=4294967295)this.bufferBuilder.append(206),this.pack_uint32(e);else if(-2147483648<=e&&e<=2147483647)this.bufferBuilder.append(210),this.pack_int32(e);else if(-0x8000000000000000<=e&&e<=0x8000000000000000)this.bufferBuilder.append(211),this.pack_int64(e);else{if(!(0<=e&&e<=0x10000000000000000))throw new Error("Invalid integer");this.bufferBuilder.append(207),this.pack_uint64(e)}},i.prototype.pack_double=function(e){var t=0;e<0&&(t=1,e=-e);var n=Math.floor(Math.log(e)/Math.LN2),r=e/Math.pow(2,n)-1,i=Math.floor(r*Math.pow(2,52)),s=Math.pow(2,32),o=t<<31|n+1023<<20|i/s&1048575,u=i%s;this.bufferBuilder.append(203),this.pack_int32(o),this.pack_int32(u)},i.prototype.pack_object=function(e){var t=Object.keys(e),n=t.length;if(n<=15)this.pack_uint8(128+n);else if(n<=65535)this.bufferBuilder.append(222),this.pack_uint16(n);else{if(!(n<=4294967295))throw new Error("Invalid length");this.bufferBuilder.append(223),this.pack_uint32(n)}for(var r in e)e.hasOwnProperty(r)&&(this.pack(r),this.pack(e[r]))},i.prototype.pack_uint8=function(e){this.bufferBuilder.append(e)},i.prototype.pack_uint16=function(e){this.bufferBuilder.append(e>>8),this.bufferBuilder.append(e&255)},i.prototype.pack_uint32=function(e){var t=e&4294967295;this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255)},i.prototype.pack_uint64=function(e){var t=e/Math.pow(2,32),n=e%Math.pow(2,32);this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255),this.bufferBuilder.append((n&4278190080)>>>24),this.bufferBuilder.append((n&16711680)>>>16),this.bufferBuilder.append((n&65280)>>>8),this.bufferBuilder.append(n&255)},i.prototype.pack_int8=function(e){this.bufferBuilder.append(e&255)},i.prototype.pack_int16=function(e){this.bufferBuilder.append((e&65280)>>8),this.bufferBuilder.append(e&255)},i.prototype.pack_int32=function(e){this.bufferBuilder.append(e>>>24&255),this.bufferBuilder.append((e&16711680)>>>16),this.bufferBuilder.append((e&65280)>>>8),this.bufferBuilder.append(e&255)},i.prototype.pack_int64=function(e){var t=Math.floor(e/Math.pow(2,32)),n=e%Math.pow(2,32);this.bufferBuilder.append((t&4278190080)>>>24),this.bufferBuilder.append((t&16711680)>>>16),this.bufferBuilder.append((t&65280)>>>8),this.bufferBuilder.append(t&255),this.bufferBuilder.append((n&4278190080)>>>24),this.bufferBuilder.append((n&16711680)>>>16),this.bufferBuilder.append((n&65280)>>>8),this.bufferBuilder.append(n&255)}})(this) |
@@ -1,8 +0,8 @@ | ||
BinaryPack = { | ||
exports.BinaryPack = { | ||
unpack: function(data){ | ||
var unpacker = new BinaryPack.Unpacker(data); | ||
var unpacker = new Unpacker(data); | ||
return unpacker.unpack(); | ||
}, | ||
pack: function(data){ | ||
var packer = new BinaryPack.Packer(); | ||
var packer = new Packer(); | ||
var buffer = packer.pack(data); | ||
@@ -13,3 +13,3 @@ return buffer; | ||
BinaryPack.Unpacker = function(data){ | ||
function Unpacker (data){ | ||
// Data is ArrayBuffer | ||
@@ -23,3 +23,3 @@ this.index = 0; | ||
BinaryPack.Unpacker.prototype.unpack = function(){ | ||
Unpacker.prototype.unpack = function(){ | ||
var type = this.unpack_uint8(); | ||
@@ -107,3 +107,3 @@ if (type < 0x80){ | ||
BinaryPack.Unpacker.prototype.unpack_uint8 = function(){ | ||
Unpacker.prototype.unpack_uint8 = function(){ | ||
var byte = this.dataView[this.index] & 0xff; | ||
@@ -114,3 +114,3 @@ this.index++; | ||
BinaryPack.Unpacker.prototype.unpack_uint16 = function(){ | ||
Unpacker.prototype.unpack_uint16 = function(){ | ||
var bytes = this.read(2); | ||
@@ -123,3 +123,3 @@ var uint16 = | ||
BinaryPack.Unpacker.prototype.unpack_uint32 = function(){ | ||
Unpacker.prototype.unpack_uint32 = function(){ | ||
var bytes = this.read(4); | ||
@@ -135,3 +135,3 @@ var uint32 = | ||
BinaryPack.Unpacker.prototype.unpack_uint64 = function(){ | ||
Unpacker.prototype.unpack_uint64 = function(){ | ||
var bytes = this.read(8); | ||
@@ -152,3 +152,3 @@ var uint64 = | ||
BinaryPack.Unpacker.prototype.unpack_int8 = function(){ | ||
Unpacker.prototype.unpack_int8 = function(){ | ||
var uint8 = this.unpack_uint8(); | ||
@@ -158,3 +158,3 @@ return (uint8 < 0x80 ) ? uint8 : uint8 - (1 << 8); | ||
BinaryPack.Unpacker.prototype.unpack_int16 = function(){ | ||
Unpacker.prototype.unpack_int16 = function(){ | ||
var uint16 = this.unpack_uint16(); | ||
@@ -164,3 +164,3 @@ return (uint16 < 0x8000 ) ? uint16 : uint16 - (1 << 16); | ||
BinaryPack.Unpacker.prototype.unpack_int32 = function(){ | ||
Unpacker.prototype.unpack_int32 = function(){ | ||
var uint32 = this.unpack_uint32(); | ||
@@ -171,3 +171,3 @@ return (uint32 < Math.pow(2, 31) ) ? uint32 : | ||
BinaryPack.Unpacker.prototype.unpack_int64 = function(){ | ||
Unpacker.prototype.unpack_int64 = function(){ | ||
var uint64 = this.unpack_uint64(); | ||
@@ -178,3 +178,3 @@ return (uint64 < Math.pow(2, 63) ) ? uint64 : | ||
BinaryPack.Unpacker.prototype.unpack_raw = function(size){ | ||
Unpacker.prototype.unpack_raw = function(size){ | ||
if ( this.length < this.index + size){ | ||
@@ -192,3 +192,3 @@ throw new Error('BinaryPackFailure: index is out of range' | ||
BinaryPack.Unpacker.prototype.unpack_string = function(size){ | ||
Unpacker.prototype.unpack_string = function(size){ | ||
var bytes = this.read(size); | ||
@@ -216,3 +216,3 @@ var i = 0, str = '', c, code; | ||
BinaryPack.Unpacker.prototype.unpack_array = function(size){ | ||
Unpacker.prototype.unpack_array = function(size){ | ||
var objects = new Array(size); | ||
@@ -225,3 +225,3 @@ for(var i = 0; i < size ; i++){ | ||
BinaryPack.Unpacker.prototype.unpack_map = function(size){ | ||
Unpacker.prototype.unpack_map = function(size){ | ||
var map = {}; | ||
@@ -236,3 +236,3 @@ for(var i = 0; i < size ; i++){ | ||
BinaryPack.Unpacker.prototype.unpack_float = function(){ | ||
Unpacker.prototype.unpack_float = function(){ | ||
var uint32 = this.unpack_uint32(); | ||
@@ -246,3 +246,3 @@ var sign = uint32 >> 31; | ||
BinaryPack.Unpacker.prototype.unpack_double = function(){ | ||
Unpacker.prototype.unpack_double = function(){ | ||
var h32 = this.unpack_uint32(); | ||
@@ -258,3 +258,3 @@ var l32 = this.unpack_uint32(); | ||
BinaryPack.Unpacker.prototype.read = function(length){ | ||
Unpacker.prototype.read = function(length){ | ||
var j = this.index; | ||
@@ -268,7 +268,7 @@ if (j + length <= this.length) { | ||
BinaryPack.Packer = function(){ | ||
function Packer (){ | ||
this.bufferBuilder = new BufferBuilder(); | ||
} | ||
BinaryPack.Packer.prototype.pack = function(value){ | ||
Packer.prototype.pack = function(value){ | ||
var type = typeof(value); | ||
@@ -298,2 +298,4 @@ if (type == 'string'){ | ||
this.pack_array(value); | ||
} else if (constructor == Blob || constructor == File) { | ||
this.pack_bin(value); | ||
} else if (constructor == ArrayBuffer) { | ||
@@ -305,3 +307,3 @@ if(binaryFeatures.useArrayBufferView) { | ||
} | ||
} else if (Uint8Array.prototype.__proto__.isPrototypeOf(value) || constructor == Blob){ | ||
} else if ('BYTES_PER_ELEMENT' in value){ | ||
if(binaryFeatures.useArrayBufferView) { | ||
@@ -329,5 +331,5 @@ this.pack_bin(value); | ||
BinaryPack.Packer.prototype.pack_bin = function(blob){ | ||
Packer.prototype.pack_bin = function(blob){ | ||
var length = blob.length || blob.byteLength || blob.size; | ||
if (length <= 0x1f){ | ||
if (length <= 0x0f){ | ||
this.pack_uint8(0xa0 + length); | ||
@@ -347,5 +349,5 @@ } else if (length <= 0xffff){ | ||
BinaryPack.Packer.prototype.pack_string = function(str){ | ||
Packer.prototype.pack_string = function(str){ | ||
var length = str.length; | ||
if (length <= 0x1f){ | ||
if (length <= 0x0f){ | ||
this.pack_uint8(0xb0 + length); | ||
@@ -365,3 +367,3 @@ } else if (length <= 0xffff){ | ||
BinaryPack.Packer.prototype.pack_array = function(ary){ | ||
Packer.prototype.pack_array = function(ary){ | ||
var length = ary.length; | ||
@@ -384,3 +386,3 @@ if (length <= 0x0f){ | ||
BinaryPack.Packer.prototype.pack_integer = function(num){ | ||
Packer.prototype.pack_integer = function(num){ | ||
if ( -0x20 <= num && num <= 0x7f){ | ||
@@ -417,3 +419,3 @@ this.bufferBuilder.append(num & 0xff); | ||
BinaryPack.Packer.prototype.pack_double = function(num){ | ||
Packer.prototype.pack_double = function(num){ | ||
var sign = 0; | ||
@@ -436,3 +438,3 @@ if (num < 0){ | ||
BinaryPack.Packer.prototype.pack_object = function(obj){ | ||
Packer.prototype.pack_object = function(obj){ | ||
var keys = Object.keys(obj); | ||
@@ -459,7 +461,7 @@ var length = keys.length; | ||
BinaryPack.Packer.prototype.pack_uint8 = function(num){ | ||
Packer.prototype.pack_uint8 = function(num){ | ||
this.bufferBuilder.append(num); | ||
} | ||
BinaryPack.Packer.prototype.pack_uint16 = function(num){ | ||
Packer.prototype.pack_uint16 = function(num){ | ||
this.bufferBuilder.append(num >> 8); | ||
@@ -469,3 +471,3 @@ this.bufferBuilder.append(num & 0xff); | ||
BinaryPack.Packer.prototype.pack_uint32 = function(num){ | ||
Packer.prototype.pack_uint32 = function(num){ | ||
var n = num & 0xffffffff; | ||
@@ -478,3 +480,3 @@ this.bufferBuilder.append((n & 0xff000000) >>> 24); | ||
BinaryPack.Packer.prototype.pack_uint64 = function(num){ | ||
Packer.prototype.pack_uint64 = function(num){ | ||
var high = num / Math.pow(2, 32); | ||
@@ -492,7 +494,7 @@ var low = num % Math.pow(2, 32); | ||
BinaryPack.Packer.prototype.pack_int8 = function(num){ | ||
Packer.prototype.pack_int8 = function(num){ | ||
this.bufferBuilder.append(num & 0xff); | ||
} | ||
BinaryPack.Packer.prototype.pack_int16 = function(num){ | ||
Packer.prototype.pack_int16 = function(num){ | ||
this.bufferBuilder.append((num & 0xff00) >> 8); | ||
@@ -502,3 +504,3 @@ this.bufferBuilder.append(num & 0xff); | ||
BinaryPack.Packer.prototype.pack_int32 = function(num){ | ||
Packer.prototype.pack_int32 = function(num){ | ||
this.bufferBuilder.append((num >>> 24) & 0xff); | ||
@@ -510,3 +512,3 @@ this.bufferBuilder.append((num & 0x00ff0000) >>> 16); | ||
BinaryPack.Packer.prototype.pack_int64 = function(num){ | ||
Packer.prototype.pack_int64 = function(num){ | ||
var high = Math.floor(num / Math.pow(2, 32)); | ||
@@ -513,0 +515,0 @@ var low = num % Math.pow(2, 32); |
@@ -1,20 +0,36 @@ | ||
var binaryFeatures = { | ||
useBlobBuilder: (function(){ | ||
try { | ||
new Blob([]); | ||
var binaryFeatures = {}; | ||
binaryFeatures.useBlobBuilder = (function(){ | ||
try { | ||
new Blob([]); | ||
return false; | ||
} catch (e) { | ||
return true; | ||
} | ||
})(); | ||
binaryFeatures.useArrayBufferView = !binaryFeatures.useBlobBuilder && (function(){ | ||
try { | ||
return (new Blob([new Uint8Array([])])).size === 0; | ||
} catch (e) { | ||
return true; | ||
} | ||
})(); | ||
binaryFeatures.supportsBinaryWebsockets = (function(){ | ||
try { | ||
var wstest = new WebSocket('ws://null'); | ||
wstest.onerror = function(){}; | ||
if (typeof(wstest.binaryType) !== "undefined") { | ||
return true; | ||
} else { | ||
return false; | ||
} catch (e) { | ||
return true; | ||
} | ||
})(), | ||
useArrayBufferView: (function(){ | ||
try { | ||
return (new Blob([new Uint8Array([])])).size === 0; | ||
} catch (e) { | ||
return true; | ||
} | ||
})() | ||
}; | ||
wstest.close(); | ||
wstest = null; | ||
} catch (e) { | ||
return false; | ||
} | ||
})(); | ||
var BlobBuilder = window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder || window.BlobBuilder; | ||
exports.binaryFeatures = binaryFeatures; | ||
exports.BlobBuilder = window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder || window.BlobBuilder; | ||
@@ -21,0 +37,0 @@ function BufferBuilder(){ |
{ | ||
"name": "js-binarypack", | ||
"version": "0.0.1", | ||
"version": "0.0.4", | ||
"description": "BinaryPack serialization for the web browser", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/binaryjs/js-binarypack", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
49053
9
1219
0
6
0
1