socket.io-parser
Advanced tools
Comparing version 3.2.0 to 3.3.0
@@ -10,4 +10,4 @@ /*global Blob,File*/ | ||
var toString = Object.prototype.toString; | ||
var withNativeBlob = typeof global.Blob === 'function' || toString.call(global.Blob) === '[object BlobConstructor]'; | ||
var withNativeFile = typeof global.File === 'function' || toString.call(global.File) === '[object FileConstructor]'; | ||
var withNativeBlob = typeof Blob === 'function' || (typeof Blob !== 'undefined' && toString.call(Blob) === '[object BlobConstructor]'); | ||
var withNativeFile = typeof File === 'function' || (typeof File !== 'undefined' && toString.call(File) === '[object FileConstructor]'); | ||
@@ -14,0 +14,0 @@ /** |
@@ -232,3 +232,3 @@ | ||
/** | ||
* Decodes an ecoded packet string into packet JSON. | ||
* Decodes an encoded packet string into packet JSON. | ||
* | ||
@@ -254,4 +254,3 @@ * @param {String} obj - encoded packet | ||
} | ||
} | ||
else if (isBuf(obj) || obj.base64) { // raw binary data | ||
} else if (isBuf(obj) || obj.base64) { // raw binary data | ||
if (!this.reconstructor) { | ||
@@ -266,4 +265,3 @@ throw new Error('got binary data when not reconstructing a packet'); | ||
} | ||
} | ||
else { | ||
} else { | ||
throw new Error('Unknown type: ' + obj); | ||
@@ -270,0 +268,0 @@ } |
module.exports = isBuf; | ||
var withNativeBuffer = typeof global.Buffer === 'function' && typeof global.Buffer.isBuffer === 'function'; | ||
var withNativeArrayBuffer = typeof global.ArrayBuffer === 'function'; | ||
var withNativeBuffer = typeof Buffer === 'function' && typeof Buffer.isBuffer === 'function'; | ||
var withNativeArrayBuffer = typeof ArrayBuffer === 'function'; | ||
var isView = (function () { | ||
if (withNativeArrayBuffer && typeof global.ArrayBuffer.isView === 'function') { | ||
return global.ArrayBuffer.isView; | ||
} else { | ||
return function (obj) { return obj.buffer instanceof global.ArrayBuffer; }; | ||
} | ||
})(); | ||
var isView = function (obj) { | ||
return typeof ArrayBuffer.isView === 'function' ? ArrayBuffer.isView(obj) : (obj.buffer instanceof ArrayBuffer); | ||
}; | ||
@@ -22,4 +18,4 @@ /** | ||
function isBuf(obj) { | ||
return (withNativeBuffer && global.Buffer.isBuffer(obj)) || | ||
(withNativeArrayBuffer && (obj instanceof global.ArrayBuffer || isView(obj))); | ||
return (withNativeBuffer && Buffer.isBuffer(obj)) || | ||
(withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj))); | ||
} |
{ | ||
"name": "socket.io-parser", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"description": "socket.io protocol parser", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -57,3 +57,3 @@ | ||
decoder.on('decoded', function(decodedPacket) { | ||
// decodedPacket.type == parser.BINARY_EVENTEVENT | ||
// decodedPacket.type == parser.BINARY_EVENT | ||
// Buffer.isBuffer(decodedPacket.data.i) == true | ||
@@ -60,0 +60,0 @@ // Buffer.isBuffer(decodedPacket.data.j) == true |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16537
484