Skip to content

Commit 50ad0cc

Browse files
committed
util: don't bother checking types before objectToString()
1 parent d2fe24e commit 50ad0cc

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lib/util.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,7 @@ exports.isUndefined = deprecate(isUndefined,
546546

547547
// note: the isRegExp function is still used here in util
548548
function isRegExp(re) {
549-
return re !== null && typeof re === 'object' &&
550-
objectToString(re) === '[object RegExp]';
549+
return objectToString(re) === '[object RegExp]';
551550
}
552551
exports.isRegExp = deprecate(isRegExp,
553552
'util.isRegExp is deprecated, please use a user-land alternative.');
@@ -560,14 +559,12 @@ exports.isObject = deprecate(isObject,
560559

561560
// still used in assert and fs
562561
function isDate(d) {
563-
return d !== null && typeof d === 'object' &&
564-
objectToString(d) === '[object Date]';
562+
return objectToString(d) === '[object Date]';
565563
}
566564
exports.isDate = isDate;
567565

568566
function isError(e) {
569-
return e !== null && typeof e === 'object' &&
570-
(objectToString(e) === '[object Error]' || e instanceof Error);
567+
return objectToString(e) === '[object Error]' || e instanceof Error;
571568
}
572569
exports.isError = deprecate(isError,
573570
'util.isError is deprecated, please use a user-land alternative.');

0 commit comments

Comments
 (0)