Skip to content

Commit

Permalink
util: removing redundant checks in is* functions
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
thefourtheye committed Jul 21, 2015
1 parent b612f08 commit 6391f4d
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down

0 comments on commit 6391f4d

Please sign in to comment.