MCPcopy Create free account
hub / github.com/visgl/react-map-gl / deepEqual

Function deepEqual

modules/react-mapbox/src/utils/deep-equal.ts:24–61  ·  view source on GitHub ↗
(a: any, b: any)

Source from the content-addressed store, hash-verified

22 * @returns true if the objects are deep equal
23 */
24export function deepEqual(a: any, b: any): boolean {
25 if (a === b) {
26 return true;
27 }
28 if (!a || !b) {
29 return false;
30 }
31 if (Array.isArray(a)) {
32 if (!Array.isArray(b) || a.length !== b.length) {
33 return false;
34 }
35 for (let i = 0; i < a.length; i++) {
36 if (!deepEqual(a[i], b[i])) {
37 return false;
38 }
39 }
40 return true;
41 } else if (Array.isArray(b)) {
42 return false;
43 }
44 if (typeof a === 'object' && typeof b === 'object') {
45 const aKeys = Object.keys(a);
46 const bKeys = Object.keys(b);
47 if (aKeys.length !== bKeys.length) {
48 return false;
49 }
50 for (const key of aKeys) {
51 if (!b.hasOwnProperty(key)) {
52 return false;
53 }
54 if (!deepEqual(a[key], b[key])) {
55 return false;
56 }
57 }
58 return true;
59 }
60 return false;
61}

Callers 7

deep-equal.spec.jsFile · 0.90
_updateSettingsMethod · 0.90
_updateHandlersMethod · 0.90
updateSourceFunction · 0.90
popup.tsFile · 0.90
updateLayerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…