You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

24 lines
712 B

module.exports = isBuf;
var withNativeBuffer = typeof global.Buffer === 'function' && typeof global.Buffer.isBuffer === 'function';
var withNativeArrayBuffer = typeof global.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; };
}
})();
/**
* Returns true if obj is a buffer or an arraybuffer.
*
* @api private
*/
function isBuf(obj) {
return (withNativeBuffer && global.Buffer.isBuffer(obj)) ||
(withNativeArrayBuffer && (obj instanceof global.ArrayBuffer || isView(obj)));
}