Mercurial > hg > nodescore
view node_modules/socket.io/node_modules/has-binary-data/index.js @ 88:54edc4cf4d44
fixes solo view refresh
author | Rob Canning <rob@foo.net> |
---|---|
date | Tue, 29 Jul 2014 00:31:38 +0100 |
parents | cd921abc8887 |
children |
line wrap: on
line source
/* * 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 recursiveCheckForBinary(obj) { if (!obj) return false; if ( (global.Buffer && 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 (recursiveCheckForBinary(obj[i])) { return true; } } } else if (obj && 'object' == typeof obj) { if (obj.toJSON) { obj = obj.toJSON(); } for (var key in obj) { if (recursiveCheckForBinary(obj[key])) { return true; } } } return false; } return recursiveCheckForBinary(data); }