2016-10-10 03:43:44 +02:00
|
|
|
/*!
|
|
|
|
* Determine if an object is a Buffer
|
|
|
|
*
|
2017-12-10 21:51:33 +01:00
|
|
|
* @author Feross Aboukhadijeh <https://feross.org>
|
2016-10-10 03:43:44 +02:00
|
|
|
* @license MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
// The _isBuffer check is for Safari 5-7 support, because it's missing
|
|
|
|
// Object.prototype.constructor. Remove this eventually
|
|
|
|
module.exports = function (obj) {
|
|
|
|
return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
|
|
|
|
}
|
|
|
|
|
|
|
|
function isBuffer (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' && isBuffer(obj.slice(0, 0))
|
|
|
|
}
|