Comparing version 1.0.5 to 1.0.6
@@ -11,20 +11,30 @@ "use strict"; | ||
}; | ||
const getDiffType = (change) => { | ||
if (change.added) | ||
return "added"; | ||
if (change.removed) | ||
return "removed"; | ||
return "default"; | ||
}; | ||
const getDiff = (original, modified) => { | ||
const changes = (0, diff_1.diffChars)(original, modified); | ||
return changes.reduce((diffCollection, change) => { | ||
const diffInfo = { | ||
type: getDiffType(change), | ||
value: change.value | ||
}; | ||
diffCollection.left.push(diffInfo); | ||
diffCollection.right.push(diffInfo); | ||
return diffCollection; | ||
}, { left: [], right: [] }); | ||
const computedDiff = { | ||
left: [], | ||
right: [], | ||
}; | ||
changes.forEach(({ added, removed, value }) => { | ||
var _a, _b, _c, _d; | ||
const diffInformation = {}; | ||
if (added) { | ||
diffInformation.type = 'added'; | ||
diffInformation.value = value; | ||
(_a = computedDiff.right) === null || _a === void 0 ? void 0 : _a.push(diffInformation); | ||
} | ||
if (removed) { | ||
diffInformation.type = 'removed'; | ||
diffInformation.value = value; | ||
(_b = computedDiff.left) === null || _b === void 0 ? void 0 : _b.push(diffInformation); | ||
} | ||
if (!removed && !added) { | ||
diffInformation.type = 'default'; | ||
diffInformation.value = value; | ||
(_c = computedDiff.right) === null || _c === void 0 ? void 0 : _c.push(diffInformation); | ||
(_d = computedDiff.left) === null || _d === void 0 ? void 0 : _d.push(diffInformation); | ||
} | ||
return diffInformation; | ||
}); | ||
return computedDiff; | ||
}; | ||
@@ -31,0 +41,0 @@ const getChanges = (original, modified) => { |
{ | ||
"name": "diffling", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "A versatile diff computation package, supporting various diff methods and line-by-line comparisons.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
10586
180
0