react-elegant-ui
Version:
Elegant UI components, made by BEM best practices for react
43 lines (42 loc) • 1.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isEqual = isEqual;
// Imported from yandex-ui. Source: https://github.com/bem/yandex-ui/
/**
* Util who compare two objects to equal values
*
* Basics on [react-fast-compare](https://github.com/FormidableLabs/react-fast-compare)
* but removed checks to unnecessary data structs.
*/
function isEqual(a, b) {
if (a === b) return true;
if (a && b && typeof a === 'object' && typeof b === 'object') {
if (a.constructor !== b.constructor) return false;
var length_1;
var i = void 0;
if (Array.isArray(a)) {
length_1 = a.length;
if (length_1 !== b.length) return false;
for (i = length_1; i-- !== 0;) if (!isEqual(a[i], b[i])) return false;
return true;
}
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
var keys = Object.keys(a);
length_1 = keys.length;
if (length_1 !== Object.keys(b).length) return false;
for (i = length_1; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
if (typeof Element !== 'undefined' && a instanceof Element) return false;
for (i = length_1; i-- !== 0;) {
if ((keys[i] === '_owner' || keys[i] === '__v' || keys[i] === '__o') && a.$$typeof) {
continue;
}
if (!isEqual(a[keys[i]], b[keys[i]])) return false;
}
return true;
}
return a !== a && b !== b;
}