Skip to content

Commit 6391f4d

Browse files
committed
util: removing redundant checks in is* functions
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: #2179 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
1 parent b612f08 commit 6391f4d

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
@@ -607,8 +607,7 @@ function isUndefined(arg) {
607607
exports.isUndefined = isUndefined;
608608

609609
function isRegExp(re) {
610-
return re !== null && typeof re === 'object' &&
611-
objectToString(re) === '[object RegExp]';
610+
return objectToString(re) === '[object RegExp]';
612611
}
613612
exports.isRegExp = isRegExp;
614613

@@ -618,14 +617,12 @@ function isObject(arg) {
618617
exports.isObject = isObject;
619618

620619
function isDate(d) {
621-
return d !== null && typeof d === 'object' &&
622-
objectToString(d) === '[object Date]';
620+
return objectToString(d) === '[object Date]';
623621
}
624622
exports.isDate = isDate;
625623

626624
function isError(e) {
627-
return e !== null && typeof e === 'object' &&
628-
(objectToString(e) === '[object Error]' || e instanceof Error);
625+
return objectToString(e) === '[object Error]' || e instanceof Error;
629626
}
630627
exports.isError = isError;
631628

0 commit comments

Comments
 (0)