@resolveio/client-lib-core 15.0.5 → 15.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/util/common.helper.mjs +14 -18
- package/fesm2015/resolveio-client-lib-core.mjs +13 -17
- package/fesm2015/resolveio-client-lib-core.mjs.map +1 -1
- package/fesm2020/resolveio-client-lib-core.mjs +13 -17
- package/fesm2020/resolveio-client-lib-core.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -472,28 +472,24 @@ function deepDiffDetails(obj1, obj2) {
|
|
|
472
472
|
}
|
|
473
473
|
return typeof value === 'string' ? `"${value}"` : String(value);
|
|
474
474
|
};
|
|
475
|
-
const formatArrayDiff = (arr1, arr2) => {
|
|
476
|
-
return arr1.map((item, index) => {
|
|
477
|
-
const arr2Item = arr2[index];
|
|
478
|
-
if (typeof item === 'object' && item !== null && arr2Item !== undefined) {
|
|
479
|
-
return `{${formatObjectDiff(item, arr2Item)}}`;
|
|
480
|
-
}
|
|
481
|
-
return arr2Item !== undefined ? `from: ${formatValue(item)} to: ${formatValue(arr2Item)}` : `removed: ${formatValue(item)}`;
|
|
482
|
-
}).join(', ');
|
|
483
|
-
};
|
|
484
475
|
const formatObjectDiff = (obj1, obj2) => {
|
|
485
476
|
if (obj1 === null || obj2 === null || typeof obj1 !== 'object' || typeof obj2 !== 'object') {
|
|
486
477
|
return `from: ${formatValue(obj1)} to: ${formatValue(obj2)}`;
|
|
487
478
|
}
|
|
488
|
-
if (Array.isArray(obj1)
|
|
489
|
-
|
|
479
|
+
if (Array.isArray(obj1) || Array.isArray(obj2)) {
|
|
480
|
+
const arr1 = Array.isArray(obj1) ? obj1 : [];
|
|
481
|
+
const arr2 = Array.isArray(obj2) ? obj2 : [];
|
|
482
|
+
const maxLength = Math.max(arr1.length, arr2.length);
|
|
483
|
+
const arrayDiff = [];
|
|
484
|
+
for (let i = 0; i < maxLength; i++) {
|
|
485
|
+
arrayDiff.push(formatObjectDiff(arr1[i], arr2[i]));
|
|
486
|
+
}
|
|
487
|
+
return `[${arrayDiff.join(', ')}]`;
|
|
490
488
|
}
|
|
491
489
|
return Object.keys({ ...obj1, ...obj2 }).map(key => {
|
|
492
|
-
const obj1Val = obj1[key]
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}
|
|
496
|
-
return `${toTitleCase(key)}: from: ${formatValue(obj1Val)} to: ${formatValue(obj2Val)}`;
|
|
490
|
+
const obj1Val = obj1 ? obj1[key] : undefined;
|
|
491
|
+
const obj2Val = obj2 ? obj2[key] : undefined;
|
|
492
|
+
return `${toTitleCase(key)}: ${formatObjectDiff(obj1Val, obj2Val)}`;
|
|
497
493
|
}).join(', ');
|
|
498
494
|
};
|
|
499
495
|
['added', 'deleted', 'updated'].forEach(diffType => {
|
|
@@ -502,7 +498,7 @@ function deepDiffDetails(obj1, obj2) {
|
|
|
502
498
|
const updates = Object.keys(diff[diffType])
|
|
503
499
|
.map(key => {
|
|
504
500
|
const currentValue = diffType === 'deleted' ? obj1[key] : obj2[key];
|
|
505
|
-
return `${toTitleCase(key)}:
|
|
501
|
+
return `${toTitleCase(key)}: ${formatObjectDiff(diff[diffType][key], currentValue)}`;
|
|
506
502
|
})
|
|
507
503
|
.join(',\n');
|
|
508
504
|
diffString += updates ? `${updates}\n` : '';
|