MCPcopy
hub / github.com/final-form/react-final-form / shallowEqual

Function shallowEqual

src/shallowEqual.ts:1–21  ·  view source on GitHub ↗
(a: any, b: any)

Source from the content-addressed store, hash-verified

1const shallowEqual = (a: any, b: any): boolean => {
2 if (a === b) {
3 return true;
4 }
5 if (typeof a !== "object" || !a || typeof b !== "object" || !b) {
6 return false;
7 }
8 var keysA = Object.keys(a);
9 var keysB = Object.keys(b);
10 if (keysA.length !== keysB.length) {
11 return false;
12 }
13 var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(b);
14 for (var idx = 0; idx < keysA.length; idx++) {
15 var key = keysA[idx];
16 if (!bHasOwnProperty(key) || a[key] !== b[key]) {
17 return false;
18 }
19 }
20 return true;
21};
22
23export default shallowEqual;

Callers 4

useFieldFunction · 0.85
useFormStateFunction · 0.85
ReactFinalFormFunction · 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…