How to use diff.convertChangesToXML:
GitHub: NeonWilderness/twoday
372 373 374 375 376 377 378 379 380 381
} else { text = `${header} is unchanged.`; process.stdout.write(chalk.grey(text)); process.stdout.write('\n'); } return { itemChanged, text, diffs: convertChangesToXML(differ) }; } diffSkin(skinName, skin1, skin2) { try {
How to use diff.diffWords:
876 877 878 879 880 881 882 883 884 885
if (urlseed.length>1) // At least two images to work with { let styledprompts = [promptseed[0]] // prefill first prompt for (var i = 1; i < promptseed.length;i++) // start on second prompt { const diff = Diff.diffWords(promptseed[i - 1], promptseed[i]) // Find differences between previous prompt and this one, Chunks into unchanged/added/removed var updateprompt = "" diff.forEach((part) => { // Bring all chunks back together with styling based on type if (part.added) {updateprompt += "<span foreground='green'><b><big>" + part.value + "</big></b></span>"} else if (part.removed) {updateprompt += "<span foreground='red'><s>" + part.value + "</s></span>"}
19
85
4
See more examples
How to use diff.diffChars:
326 327 328 329 330 331 332 333 334 335
if (ignoreWhitespace) { received = received.replace(/\s/g,''); input = input.replace(/\s/g,''); } let diff = jsdiff.diffChars(received, input); diff.forEach(function (part) { // green for additions, red for deletions // grey for common parts if (part.added) {
How to use diff.structuredPatch:
776 777 778 779 780 781 782 783 784 785
tap((params) => { assert(contentFormated); assert(contentOld); }), () => Diff.structuredPatch( `${filename}.old`, `${filename}.new`, contentOld, contentFormated,
12
78
0
See more examples
How to use diff.diffLines:
44 45 46 47 48 49 50 51 52 53
))); console.log(colorette.gray("BEGIN >>>")); if (fileMode) { const diff$1 = diff.diffLines(source, code); let message = ""; diff$1.forEach((part) => {
How to use diff.push:
GitHub: iykeori/LaravelCapstone
11787 11788 11789 11790 11791 11792 11793 11794 11795 11796
ret.push('==================================================================='); ret.push('--- ' + oldFileName + (typeof oldHeader === 'undefined' ? '' : '\t' + oldHeader)); ret.push('+++ ' + newFileName + (typeof newHeader === 'undefined' ? '' : '\t' + newHeader)); var diff = PatchDiff.diff(oldStr, newStr); diff.push({value: '', lines: []}); // Append an empty value to make cleanup easier // Formats a given set of lines for printing as context lines in a patch function contextLines(lines) { return map(lines, function(entry) { return ' ' + entry; });
How to use diff.createPatch:
GitHub: iykeori/LaravelCapstone
1989 1990 1991 1992 1993 1994 1995 1996 1997 1998
return indent + line; } function notBlank(line) { return typeof line !== 'undefined' && line !== null; } var msg = diff.createPatch('string', err.actual, err.expected); var lines = msg.split('\n').splice(4); return '\n ' + colorLines('diff added', '+ expected') + ' ' + colorLines('diff removed', '- actual')