1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4 | Object.defineProperty(exports, "__esModule", {
|
5 | value: true
|
6 | });
|
7 | exports.default = void 0;
|
8 | var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
9 | var _warning = _interopRequireDefault(require("./warning"));
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | function isEqual(obj1, obj2) {
|
18 | var shallow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
19 |
|
20 | var refSet = new Set();
|
21 | function deepEqual(a, b) {
|
22 | var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
23 | var circular = refSet.has(a);
|
24 | (0, _warning.default)(!circular, 'Warning: There may be circular references');
|
25 | if (circular) {
|
26 | return false;
|
27 | }
|
28 | if (a === b) {
|
29 | return true;
|
30 | }
|
31 | if (shallow && level > 1) {
|
32 | return false;
|
33 | }
|
34 | refSet.add(a);
|
35 | var newLevel = level + 1;
|
36 | if (Array.isArray(a)) {
|
37 | if (!Array.isArray(b) || a.length !== b.length) {
|
38 | return false;
|
39 | }
|
40 | for (var i = 0; i < a.length; i++) {
|
41 | if (!deepEqual(a[i], b[i], newLevel)) {
|
42 | return false;
|
43 | }
|
44 | }
|
45 | return true;
|
46 | }
|
47 | if (a && b && (0, _typeof2.default)(a) === 'object' && (0, _typeof2.default)(b) === 'object') {
|
48 | var keys = Object.keys(a);
|
49 | if (keys.length !== Object.keys(b).length) {
|
50 | return false;
|
51 | }
|
52 | return keys.every(function (key) {
|
53 | return deepEqual(a[key], b[key], newLevel);
|
54 | });
|
55 | }
|
56 |
|
57 | return false;
|
58 | }
|
59 | return deepEqual(obj1, obj2);
|
60 | }
|
61 | var _default = exports.default = isEqual; |
\ | No newline at end of file |