securityos/node_modules/buffer-es6/is-buffer.js

16 lines
673 B
JavaScript
Raw Permalink Normal View History

2024-09-06 15:32:35 +00:00
// the following is from is-buffer, also by Feross Aboukhadijeh and with same lisence
// The _isBuffer check is for Safari 5-7 support, because it's missing
// Object.prototype.constructor. Remove this eventually
export function isBuffer(obj) {
return obj != null && (isFastBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
}
function isFastBuffer (obj) {
return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
}
// For Node v0.10 support. Remove this eventually.
function isSlowBuffer (obj) {
return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isFastBuffer(obj.slice(0, 0))
}