From 13c948e661f4a077bbc788dcb9d3c2c1b403d010 Mon Sep 17 00:00:00 2001 From: Alanscut <948467222@qq.com> Date: Mon, 9 Dec 2019 10:28:37 +0800 Subject: [PATCH] Remove 'includes' API, fix CI build failure (#2574) * Remove 'includes' API, fix CI build failure --- lib/utils.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) 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 *