From 6391f4d2fd7a5779e012887158e6bc69d08966e3 Mon Sep 17 00:00:00 2001 From: Sakthipriyan Vairamani Date: Wed, 15 Jul 2015 01:56:54 +0530 Subject: [PATCH] util: removing redundant checks in is* functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When Object.prototype.toString is used to determine the type, we don't have to explicitly check for other types. This patch removes the redundant checks like that. PR-URL: https://github.com/nodejs/io.js/pull/2179 Reviewed-By: Colin Ihrig Reviewed-By: Michaƫl Zasso Reviewed-By: Jeremiah Senkpiel --- lib/util.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/util.js b/lib/util.js index 89017450e026ae..37f2a07ba27a4f 100644 --- a/lib/util.js +++ b/lib/util.js @@ -607,8 +607,7 @@ function isUndefined(arg) { exports.isUndefined = isUndefined; function isRegExp(re) { - return re !== null && typeof re === 'object' && - objectToString(re) === '[object RegExp]'; + return objectToString(re) === '[object RegExp]'; } exports.isRegExp = isRegExp; @@ -618,14 +617,12 @@ function isObject(arg) { exports.isObject = isObject; function isDate(d) { - return d !== null && typeof d === 'object' && - objectToString(d) === '[object Date]'; + return objectToString(d) === '[object Date]'; } exports.isDate = isDate; function isError(e) { - return e !== null && typeof e === 'object' && - (objectToString(e) === '[object Error]' || e instanceof Error); + return objectToString(e) === '[object Error]' || e instanceof Error; } exports.isError = isError;