MCPcopy Create free account
hub / github.com/sshwsfc/xadmin / shallowEqual

Function shallowEqual

packages/xadmin/src/wrap.js:9–33  ·  view source on GitHub ↗
(objA, objB, ingoreKey)

Source from the content-addressed store, hash-verified

7}
8
9const shallowEqual = (objA, objB, ingoreKey) => {
10 if (objA === objB) {
11 return true
12 }
13 if((objA == undefined && objB != undefined) || (objB == undefined && objA != undefined)
14 || (objA == null && objB != null) || (objB == null && objA != null)) {
15 return false
16 }
17
18 const keysA = Object.keys(objA)
19 const keysB = Object.keys(objB)
20
21 if (keysA.length !== keysB.length) {
22 return false
23 }
24 // Test for A's keys different from B.
25 const hasOwn = Object.prototype.hasOwnProperty
26 for (let i = 0; i < keysA.length; i++) {
27 if (!hasOwn.call(objB, keysA[i]) ||
28 (keysA[i] != ingoreKey && objA[keysA[i]] !== objB[keysA[i]])) {
29 return false
30 }
31 }
32 return true
33}
34
35const wrap_component = (WrappedComponent, tag, defaultMapper) => {
36 const app = window.__app__

Callers 4

getDerivedStateFromPropsFunction · 0.85
shouldComponentUpdateFunction · 0.85
ifFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected