earljs
Version:
Ergonomic, modern and type-safe assertion library
31 lines (30 loc) • 1.02 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.isEqualObject = void 0;
const getKeys_1 = require("./getKeys");
const isEqualUnknown_1 = require("./isEqualUnknown");
function isEqualObject(value, valueStack, other, otherStack, options, type) {
const keys = (0, getKeys_1.getKeys)(value, type, options);
const otherKeys = (0, getKeys_1.getKeys)(other, type, options);
if (keys.length !== otherKeys.length) {
return false;
}
for (let i = 0; i < keys.length; i++) {
if (keys[i] !== otherKeys[i]) {
return false;
}
}
valueStack.push(value);
otherStack.push(other);
let result = true;
for (let i = 0; i < keys.length; i++) {
if (!(0, isEqualUnknown_1.isEqualUnknown)(value[keys[i]], valueStack, other[otherKeys[i]], otherStack, options)) {
result = false;
break;
}
}
valueStack.pop();
otherStack.pop();
return result;
}
exports.isEqualObject = isEqualObject;
;