@resolveio/client-lib-core 15.0.4 → 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 +18 -38
- package/fesm2015/resolveio-client-lib-core.mjs +17 -37
- package/fesm2015/resolveio-client-lib-core.mjs.map +1 -1
- package/fesm2020/resolveio-client-lib-core.mjs +17 -37
- package/fesm2020/resolveio-client-lib-core.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -472,54 +472,34 @@ function deepDiffDetails(obj1, obj2) {
|
|
|
472
472
|
}
|
|
473
473
|
return typeof value === 'string' ? `"${value}"` : String(value);
|
|
474
474
|
};
|
|
475
|
-
const formatArrayDiff = (arr1, arr2) => {
|
|
476
|
-
let maxLength = Math.max(arr1.length, arr2.length);
|
|
477
|
-
let arrayDiff = [];
|
|
478
|
-
for (let i = 0; i < maxLength; i++) {
|
|
479
|
-
if (i >= arr1.length) {
|
|
480
|
-
arrayDiff.push(`added: ${formatValue(arr2[i])}`);
|
|
481
|
-
continue;
|
|
482
|
-
}
|
|
483
|
-
if (i >= arr2.length) {
|
|
484
|
-
arrayDiff.push(`removed: ${formatValue(arr1[i])}`);
|
|
485
|
-
continue;
|
|
486
|
-
}
|
|
487
|
-
if (arr1[i] !== arr2[i]) {
|
|
488
|
-
arrayDiff.push(`from: ${formatValue(arr1[i])} to: ${formatValue(arr2[i])}`);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
return `[${arrayDiff.join(', ')}]`;
|
|
492
|
-
};
|
|
493
475
|
const formatObjectDiff = (obj1, obj2) => {
|
|
494
476
|
if (obj1 === null || obj2 === null || typeof obj1 !== 'object' || typeof obj2 !== 'object') {
|
|
495
477
|
return `from: ${formatValue(obj1)} to: ${formatValue(obj2)}`;
|
|
496
478
|
}
|
|
497
|
-
if (Array.isArray(obj1)
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
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]));
|
|
503
486
|
}
|
|
504
|
-
return
|
|
505
|
-
}).join(', ');
|
|
506
|
-
};
|
|
507
|
-
const handleDiffType = (diffObj, obj, key) => {
|
|
508
|
-
if (Array.isArray(diffObj[key])) {
|
|
509
|
-
return `${toTitleCase(key)}: ${formatArrayDiff(obj1[key] || [], obj2[key] || [])}`;
|
|
510
|
-
}
|
|
511
|
-
else if (typeof diffObj[key] === 'object') {
|
|
512
|
-
return `${toTitleCase(key)}: {${formatObjectDiff(obj1[key], obj2[key])}}`;
|
|
513
|
-
}
|
|
514
|
-
else {
|
|
515
|
-
return `${toTitleCase(key)}: from: ${formatValue(obj1[key])} to: ${formatValue(obj2[key])}`;
|
|
487
|
+
return `[${arrayDiff.join(', ')}]`;
|
|
516
488
|
}
|
|
489
|
+
return Object.keys({ ...obj1, ...obj2 }).map(key => {
|
|
490
|
+
const obj1Val = obj1 ? obj1[key] : undefined;
|
|
491
|
+
const obj2Val = obj2 ? obj2[key] : undefined;
|
|
492
|
+
return `${toTitleCase(key)}: ${formatObjectDiff(obj1Val, obj2Val)}`;
|
|
493
|
+
}).join(', ');
|
|
517
494
|
};
|
|
518
495
|
['added', 'deleted', 'updated'].forEach(diffType => {
|
|
519
496
|
if (Object.keys(diff[diffType]).length > 0) {
|
|
520
497
|
diffString += `${toTitleCase(diffType)}:\n`;
|
|
521
498
|
const updates = Object.keys(diff[diffType])
|
|
522
|
-
.map(key =>
|
|
499
|
+
.map(key => {
|
|
500
|
+
const currentValue = diffType === 'deleted' ? obj1[key] : obj2[key];
|
|
501
|
+
return `${toTitleCase(key)}: ${formatObjectDiff(diff[diffType][key], currentValue)}`;
|
|
502
|
+
})
|
|
523
503
|
.join(',\n');
|
|
524
504
|
diffString += updates ? `${updates}\n` : '';
|
|
525
505
|
}
|