MCPcopy
hub / github.com/visgl/deck.gl / deepEqual

Function deepEqual

modules/core/src/utils/deep-equal.ts:13–51  ·  view source on GitHub ↗
(a: any, b: any, depth: number)

Source from the content-addressed store, hash-verified

11 */
12/* eslint-disable complexity */
13export function deepEqual(a: any, b: any, depth: number): boolean {
14 if (a === b) {
15 return true;
16 }
17 if (!depth || !a || !b) {
18 return false;
19 }
20 if (Array.isArray(a)) {
21 if (!Array.isArray(b) || a.length !== b.length) {
22 return false;
23 }
24 for (let i = 0; i < a.length; i++) {
25 if (!deepEqual(a[i], b[i], depth - 1)) {
26 return false;
27 }
28 }
29 return true;
30 }
31 if (Array.isArray(b)) {
32 return false;
33 }
34 if (typeof a === 'object' && typeof b === 'object') {
35 const aKeys = Object.keys(a);
36 const bKeys = Object.keys(b);
37 if (aKeys.length !== bKeys.length) {
38 return false;
39 }
40 for (const key of aKeys) {
41 if (!b.hasOwnProperty(key)) {
42 return false;
43 }
44 if (!deepEqual(a[key], b[key], depth - 1)) {
45 return false;
46 }
47 }
48 return true;
49 }
50 return false;
51}

Callers 15

setPropsFunction · 0.90
equalFunction · 0.90
setPropsMethod · 0.90
setPropsFunction · 0.90
setPropsMethod · 0.90
equalsFunction · 0.90
setPropsMethod · 0.90
_setViewStateMethod · 0.90
equalsFunction · 0.90
deep-equal.spec.tsFile · 0.90
deepEqualBenchFunction · 0.90
useWidgetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…