some more slight improvements to exam changes logs

This commit is contained in:
Joao Correia
2025-03-02 14:27:17 +00:00
parent 3ef7998193
commit 75fb9490e0
2 changed files with 10 additions and 13 deletions

View File

@@ -129,7 +129,6 @@ function compareObjects(oldObj: any, newObj: any, path: (string | number)[], dif
}
const oldIndexMap = new Map(oldObj.map((item: any, index: number) => [getIdentifier(item), index]));
let reorderDetected = false;
// Process items in the new array using their order.
for (let i = 0; i < newObj.length; i++) {
const newItem = newObj[i];
@@ -138,9 +137,6 @@ function compareObjects(oldObj: any, newObj: any, path: (string | number)[], dif
if (oldIndexMap.has(identifier)) {
const oldIndex = oldIndexMap.get(identifier)!;
const oldItem = oldObj[oldIndex];
if (oldIndex !== i) {
reorderDetected = true;
}
compareObjects(oldItem, newItem, path.concat(`#${i + 1}`), differences);
} else {
differences.push(`• Added new ${getArrayItemLabel(path)} #${i + 1} at ${pathToHumanReadable(path)}\n`);
@@ -150,9 +146,6 @@ function compareObjects(oldObj: any, newObj: any, path: (string | number)[], dif
compareObjects(oldObj[i], newItem, path.concat(`#${i + 1}`), differences);
}
}
if (reorderDetected) {
differences.push(`• Reordered Items at ${pathToHumanReadable(path)}\n`);
}
} else {
// For arrays that are not identifier-based, compare element by element.
const maxLength = Math.max(oldObj.length, newObj.length);