@antdv/pro-utils
Version:
@antdv/pro-utils
93 lines (92 loc) • 3.1 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var stdin_exports = {};
__export(stdin_exports, {
isDeepEqual: () => isDeepEqual
});
module.exports = __toCommonJS(stdin_exports);
function isDeepEqual(a, b, ignoreKeys, debug) {
if (a === b) return true;
if (a && b && typeof a === "object" && typeof b === "object") {
if (a.constructor !== b.constructor) return false;
let length;
let i;
let keys;
if (Array.isArray(a)) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0; ) {
if (!isDeepEqual(a[i], b[i], ignoreKeys, debug)) return false;
}
return true;
}
if (a instanceof Map && b instanceof Map) {
if (a.size !== b.size) return false;
for (i of a.entries()) {
if (!b.has(i[0])) return false;
}
for (i of a.entries()) {
if (!isDeepEqual(i[1], b.get(i[0]), ignoreKeys, debug))
return false;
}
return true;
}
if (a instanceof Set && b instanceof Set) {
if (a.size !== b.size) return false;
for (i of a.entries()) {
if (!b.has(i[0])) return false;
}
return true;
}
if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0; ) {
if (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 && a.valueOf)
return a.valueOf() === b.valueOf();
if (a.toString !== Object.prototype.toString && a.toString)
return a.toString() === b.toString();
keys = Object.keys(a);
length = keys.length;
if (length !== Object.keys(b).length) return false;
for (i = length; i-- !== 0; ) {
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
}
for (i = length; i-- !== 0; ) {
const key = keys[i];
if (ignoreKeys == null ? void 0 : ignoreKeys.includes(key)) continue;
if (key === "_owner" && a.$$typeof) {
continue;
}
if (!isDeepEqual(a[key], b[key], ignoreKeys, debug)) {
if (debug) {
console.log(key);
}
return false;
}
}
return true;
}
return a !== a && b !== b;
}