From 50ad0cc3cc37bd5d6634a7f5523d8e01c10c9b91 Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Wed, 8 Apr 2015 10:37:27 -0400 Subject: [PATCH] util: don't bother checking types before objectToString() --- lib/util.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/util.js b/lib/util.js index faee48daacbf93..f6f76825c0a6db 100644 --- a/lib/util.js +++ b/lib/util.js @@ -546,8 +546,7 @@ exports.isUndefined = deprecate(isUndefined, // note: the isRegExp function is still used here in util function isRegExp(re) { - return re !== null && typeof re === 'object' && - objectToString(re) === '[object RegExp]'; + return objectToString(re) === '[object RegExp]'; } exports.isRegExp = deprecate(isRegExp, 'util.isRegExp is deprecated, please use a user-land alternative.'); @@ -560,14 +559,12 @@ exports.isObject = deprecate(isObject, // still used in assert and fs 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 = deprecate(isError, 'util.isError is deprecated, please use a user-land alternative.');