mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
Removed has-binary-data dependency
And replaced it with better isBuf function. Has binary data would not have checked objects that contain blobs. isBuf only checks the current object, not its child objects
This commit is contained in:
15
binary.js
15
binary.js
@@ -3,7 +3,6 @@
|
||||
*/
|
||||
|
||||
var isArray = require('isarray');
|
||||
var hasBin = require('has-binary-data');
|
||||
|
||||
/**
|
||||
* Replaces every Buffer | ArrayBuffer in packet with a numbered placeholder.
|
||||
@@ -127,7 +126,7 @@ exports.removeBlobs = function(data, callback) {
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
removeBlobsRecursive(obj[i], i, obj);
|
||||
}
|
||||
} else if (obj && 'object' == typeof obj && !hasBin(obj)) { // and object
|
||||
} else if (obj && 'object' == typeof obj && !isBuf(obj)) { // and object
|
||||
for (var key in obj) {
|
||||
removeBlobsRecursive(obj[key], key, obj);
|
||||
}
|
||||
@@ -140,4 +139,14 @@ exports.removeBlobs = function(data, callback) {
|
||||
if (!pendingBlobs) {
|
||||
callback(bloblessData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if obj is a buffer or an arraybuffer.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
function isBuf(obj) {
|
||||
return (global.Buffer && Buffer.isBuffer(obj)) ||
|
||||
(global.ArrayBuffer && obj instanceof ArrayBuffer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user