Init. Map does not function and only working on backend at the moment.
This commit is contained in:
59
node_modules/has-binary/index.js
generated
vendored
Normal file
59
node_modules/has-binary/index.js
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
|
||||
/*
|
||||
* Module requirements.
|
||||
*/
|
||||
|
||||
var isArray = require('isarray');
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = hasBinary;
|
||||
|
||||
/**
|
||||
* Checks for binary data.
|
||||
*
|
||||
* Right now only Buffer and ArrayBuffer are supported..
|
||||
*
|
||||
* @param {Object} anything
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function hasBinary(data) {
|
||||
|
||||
function _hasBinary(obj) {
|
||||
if (!obj) return false;
|
||||
|
||||
if ( (global.Buffer && global.Buffer.isBuffer && global.Buffer.isBuffer(obj)) ||
|
||||
(global.ArrayBuffer && obj instanceof ArrayBuffer) ||
|
||||
(global.Blob && obj instanceof Blob) ||
|
||||
(global.File && obj instanceof File)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isArray(obj)) {
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
if (_hasBinary(obj[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (obj && 'object' == typeof obj) {
|
||||
// see: https://github.com/Automattic/has-binary/pull/4
|
||||
if (obj.toJSON && 'function' == typeof obj.toJSON) {
|
||||
obj = obj.toJSON();
|
||||
}
|
||||
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key) && _hasBinary(obj[key])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return _hasBinary(data);
|
||||
}
|
Reference in New Issue
Block a user