diff --git a/lib/utils.js b/lib/utils.js index c985b0a954..e028c6763e 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -18,6 +18,15 @@ function isArray(val) { return toString.call(val) === '[object Array]'; } +/** + * Determine if a value is undefined + * + * @param {Object} val The value to test + * @returns {boolean} True if the value is undefined, otherwise false + */ +function isUndefined(val) { + return typeof val === 'undefined'; +} /** * Determine if a value is a Buffer @@ -26,7 +35,8 @@ function isArray(val) { * @returns {boolean} True if value is a Buffer, otherwise false */ function isBuffer(val) { - return ![undefined, null].includes(val) && val.constructor === Buffer; + return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) + && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); } /** @@ -85,16 +95,6 @@ function isNumber(val) { return typeof val === 'number'; } -/** - * Determine if a value is undefined - * - * @param {Object} val The value to test - * @returns {boolean} True if the value is undefined, otherwise false - */ -function isUndefined(val) { - return typeof val === 'undefined'; -} - /** * Determine if a value is an Object *