From 06533df372b1f094dc7df41598c3ab2ab4be60b1 Mon Sep 17 00:00:00 2001 From: Alanscut Date: Wed, 27 Nov 2019 14:31:10 +0800 Subject: [PATCH 1/3] Remove 'includes' API, fix CI build failure --- lib/utils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index c985b0a954..c01e605949 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -26,7 +26,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; + if (val === null || val === void 0 || val.constructor === null || val.constructor === void 0 ) return false; + return typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); } /** From 33c8895e038ce1c9632bfbb05a7b80a06b730f74 Mon Sep 17 00:00:00 2001 From: Alanscut Date: Fri, 6 Dec 2019 09:45:54 +0800 Subject: [PATCH 2/3] request change --- lib/utils.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index c01e605949..42e2dfde72 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,7 @@ function isArray(val) { * @returns {boolean} True if value is a Buffer, otherwise false */ function isBuffer(val) { - if (val === null || val === void 0 || val.constructor === null || val.constructor === void 0 ) return false; + if (val === null || isUndefined(val) || val.constructor === null || isUndefined(val.constructor)) return false; return typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); } @@ -86,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 * From ba16c9ac25c22178e1058fb133227dc7a22503dd Mon Sep 17 00:00:00 2001 From: Alanscut Date: Fri, 6 Dec 2019 17:46:18 +0800 Subject: [PATCH 3/3] request changes --- lib/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index 42e2dfde72..e028c6763e 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -35,8 +35,8 @@ function isUndefined(val) { * @returns {boolean} True if value is a Buffer, otherwise false */ function isBuffer(val) { - if (val === null || isUndefined(val) || val.constructor === null || isUndefined(val.constructor)) return false; - return typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); + return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) + && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); } /**