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.
26 lines
579 B
26 lines
579 B
'use strict';
|
|
|
|
/**
|
|
* FUNCTION: isBuffer( value )
|
|
* Validates if a value is a Buffer object.
|
|
*
|
|
* @param {*} value - value to validate
|
|
* @returns {Boolean} boolean indicating if a value is a Buffer object
|
|
*/
|
|
function isBuffer( val ) {
|
|
return typeof val === 'object' &&
|
|
val !== null &&
|
|
(
|
|
val._isBuffer || // for envs missing Object.prototype.constructor (e.g., Safari 5-7)
|
|
(
|
|
val.constructor &&
|
|
typeof val.constructor.isBuffer === 'function' &&
|
|
val.constructor.isBuffer( val )
|
|
)
|
|
);
|
|
} // end FUNCTION isBuffer()
|
|
|
|
|
|
// EXPORTS //
|
|
|
|
module.exports = isBuffer;
|
|
|