Skip to content

Commit 7acc3e9

Browse files
authored
Update index.js
1 parent cddf4fb commit 7acc3e9

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

index.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
//
22

3-
function defaultCompare(a, b) {
4-
// `NaN === NaN` returns `false`
5-
// see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN#Polyfill
6-
return a === b || (typeof a === 'number' && a !== a && typeof b === 'number' && b !== b);
7-
}
8-
93
module.exports = function shallowEqual(objA, objB, compare, compareContext) {
104
var ret = compare ? compare.call(compareContext, objA, objB) : void 0;
115

126
if (ret !== void 0) {
137
return !!ret;
148
}
159

16-
if (defaultCompare(objA, objB)) {
10+
if (Object.is(objA, objB)) {
1711
return true;
1812
}
1913

@@ -43,7 +37,7 @@ module.exports = function shallowEqual(objA, objB, compare, compareContext) {
4337

4438
ret = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;
4539

46-
if (ret === false || (ret === void 0 && !defaultCompare(valueA, valueB))) {
40+
if (ret === false || (ret === void 0 && !Object.is(valueA, valueB))) {
4741
return false;
4842
}
4943
}

0 commit comments

Comments
 (0)