Skip to content

Commit

Permalink
[Refactor] there is no need to do further compareation when two types…
Browse files Browse the repository at this point in the history
… are not equal
  • Loading branch information
yubaoquan authored and ljharb committed Jan 20, 2017
1 parent 28fde4a commit 6a5efc1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"eqeqeq": 1,
"func-style": [2, "declaration"],
"indent": [2, 2],
"max-lines-per-function": [2, 75],
"max-params": [2, 3],
"strict": 1,
},
Expand Down
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function deepEqual(actual, expected, options) {
}

// 7.3. Other pairs that do not both pass typeof value == 'object', equivalence is determined by ==.
if (!actual || !expected || (typeof actual != 'object' && typeof expected != 'object')) {
if (!actual || !expected || (typeof actual !== 'object' && typeof expected !== 'object')) {
return opts.strict ? is(actual, expected) : actual == expected;
}

Expand Down Expand Up @@ -79,6 +79,10 @@ function objEquiv(a, b, opts) {
return true;
}

if (typeof a !== typeof b) {
return false;
}

try {
var ka = objectKeys(a);
var kb = objectKeys(b);
Expand Down Expand Up @@ -107,7 +111,7 @@ function objEquiv(a, b, opts) {
}
}

return typeof a === typeof b;
return true;
}

module.exports = deepEqual;

0 comments on commit 6a5efc1

Please sign in to comment.