source: trip-planner-front/node_modules/fast-deep-equal/react.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.4 KB
Line 
1'use strict';
2
3// do not edit .js files directly - edit src/index.jst
4
5
6
7module.exports = function equal(a, b) {
8 if (a === b) return true;
9
10 if (a && b && typeof a == 'object' && typeof b == 'object') {
11 if (a.constructor !== b.constructor) return false;
12
13 var length, i, keys;
14 if (Array.isArray(a)) {
15 length = a.length;
16 if (length != b.length) return false;
17 for (i = length; i-- !== 0;)
18 if (!equal(a[i], b[i])) return false;
19 return true;
20 }
21
22
23
24 if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
25 if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
26 if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
27
28 keys = Object.keys(a);
29 length = keys.length;
30 if (length !== Object.keys(b).length) return false;
31
32 for (i = length; i-- !== 0;)
33 if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
34
35 for (i = length; i-- !== 0;) {
36 var key = keys[i];
37
38 if (key === '_owner' && a.$$typeof) {
39 // React-specific: avoid traversing React elements' _owner.
40 // _owner contains circular references
41 // and is not needed when comparing the actual elements (and not their owners)
42 continue;
43 }
44
45 if (!equal(a[key], b[key])) return false;
46 }
47
48 return true;
49 }
50
51 // true if both NaN, false otherwise
52 return a!==a && b!==b;
53};
Note: See TracBrowser for help on using the repository browser.