16 lines
673 B
JavaScript
16 lines
673 B
JavaScript
|
// 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))
|
||
|
}
|