(obj1, obj2)
| 1290 | } |
| 1291 | |
| 1292 | function isEqualIgnoringSomeKeys (obj1, obj2) { |
| 1293 | // If both are the same object or both are null/undefined, they are equal |
| 1294 | if (obj1 === obj2) return true |
| 1295 | |
| 1296 | // If either is not an object (and they are not equal), they are not equal |
| 1297 | if (!_.isObject(obj1) || !_.isObject(obj2)) return false |
| 1298 | |
| 1299 | // Get keys from both objects |
| 1300 | const keys1 = _.without(Object.keys(obj1), ...keysToIgnore) |
| 1301 | const keys2 = _.without(Object.keys(obj2), ...keysToIgnore) |
| 1302 | |
| 1303 | for (const key of _.union(keys1, keys2)) { |
| 1304 | // Treat as equal if the key should be ignored when empty and both values are empty |
| 1305 | if (keysToIgnoreWhenEmpty.includes(key)) { |
| 1306 | if (isEmptyOrUndefined(obj1[key]) && isEmptyOrUndefined(obj2[key])) { |
| 1307 | continue |
| 1308 | } |
| 1309 | } |
| 1310 | |
| 1311 | // If both values are objects, compare recursively |
| 1312 | if (_.isObject(obj1[key]) && _.isObject(obj2[key])) { |
| 1313 | if (!isEqualIgnoringSomeKeys(obj1[key], obj2[key])) return false |
| 1314 | } |
| 1315 | // For non-object values, use Lodash's isEqual for comparison |
| 1316 | else { |
| 1317 | if (!_.isEqual(obj1[key], obj2[key])) return false |
| 1318 | } |
| 1319 | } |
| 1320 | |
| 1321 | return true |
| 1322 | } |
| 1323 | |
| 1324 | return isEqualIgnoringSomeKeys(state1, state2) |
| 1325 | } |
no test coverage detected