Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getFormattedDiff(oldObject, newObject): string {
let oldJson = JSON.stringify(oldObject, null, 4);
let newJson = JSON.stringify(newObject, null, 4);
// TODO: remove if angular supports styling inner-html
// This is an icky hack but we must do it since Angular doesn't
// currently apply View styles to nodes inserted via inner-html
return JsDiff.convertChangesToXML(JsDiff.diffLines(oldJson, newJson)) +
`\n<style>
ins {
text-decoration:none;
color: #4F8A10;
background-color: #DFF2BF;
}
del {
color: #D8000C;
background-color: #FFBABA;
}
</style>`;
}
getDiff(newFlag, oldFlag) {
const o = JSON.parse(JSON.stringify(oldFlag));
const n = JSON.parse(JSON.stringify(newFlag));
const d = diffJson(o, n);
if (d.length === 1) {
return "No changes";
}
return convertChangesToXML(d);
}
},