MCPcopy
hub / github.com/heroku/react-refetch / shallowEqual

Function shallowEqual

src/utils/shallowEqual.js:1–28  ·  view source on GitHub ↗
(objA, objB)

Source from the content-addressed store, hash-verified

1export default function shallowEqual(objA, objB) {
2 if (objA === objB) {
3 return true
4 }
5
6 if (typeof objA !== 'object' || typeof objB !== 'object' ||
7 objA === null || objB === null) {
8 return false
9 }
10
11 const keysA = Object.keys(objA)
12 const keysB = Object.keys(objB)
13
14 if (keysA.length !== keysB.length) {
15 return false
16 }
17
18 // Test for A's keys different from B.
19 const hasOwn = Object.prototype.hasOwnProperty
20 for (let i = 0; i < keysA.length; i++) {
21 if (!hasOwn.call(objB, keysA[i]) ||
22 objA[keysA[i]] !== objB[keysA[i]]) {
23 return false
24 }
25 }
26
27 return true
28}

Callers 4

coerceMappingFunction · 0.85
componentDidUpdateMethod · 0.85
shouldComponentUpdateMethod · 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…