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:
Kevin Roark
2014-03-05 00:20:52 -05:00
parent 47df0694f5
commit ba64f07bca
2 changed files with 13 additions and 5 deletions

View File

@@ -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);
}