feat: better handling for message edits
Code Analysis / SonarQube (push) Failing after 18s
Node.js CI / Lint and Test (push) Failing after 33s

This commit is contained in:
2025-07-08 13:43:14 -07:00
parent c47c46e69a
commit 91d7a1ef28
4 changed files with 39 additions and 7 deletions
+22
View File
@@ -0,0 +1,22 @@
import { diffSentences } from "diff";
/**
* Module to generate a diff string from two strings.
* @param old - The old string.
* @param updated - The new string.
* @returns The diff string, formatted.
*/
export const generateDiff = (old: string, updated: string): string => {
return diffSentences(old, updated).
map((element) => {
if (element.added) {
return `+ ${element.value}`;
}
if (element.removed) {
return `- ${element.value}`;
}
return "";
}).
filter(Boolean).
join("\n");
};