UNPKG

899 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const hasOwnProperty = Object.prototype.hasOwnProperty;
4function is(x, y) {
5 if (x === y) {
6 return x !== 0 || y !== 0 || 1 / x === 1 / y;
7 }
8 return x !== x && y !== y;
9}
10function shallowEqual(objA, objB) {
11 if (is(objA, objB)) {
12 return true;
13 }
14 if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
15 return false;
16 }
17 const keysA = Object.keys(objA);
18 const keysB = Object.keys(objB);
19 if (keysA.length !== keysB.length) {
20 return false;
21 }
22 for (let i = 0; i < keysA.length; i++) {
23 if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
24 return false;
25 }
26 }
27 return true;
28}
29exports.shallowEqual = shallowEqual;
30
31//# sourceMappingURL=shallowEqual.js.map