@zohodesk/components
Version:
Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development
28 lines (22 loc) • 602 B
JavaScript
function isSame(a, b) {
return a === b;
}
const {
hasOwnProperty
} = Object.prototype;
export default function shallowCompare(objA, objB) {
if (objA && objB && typeof objA === 'object' && typeof objB === 'object') {
const keysA = Object.keys(objA);
const keysB = Object.keys(objB);
if (keysA.length !== keysB.length) {
return false;
} // Test for A's keys different from B.
for (let key of keysA) {
if (!hasOwnProperty.call(objB, key) || !isSame(objA[key], objB[key])) {
return false;
}
}
return true;
}
return isSame(objA, objB);
}