Function diffStr
- diff
Str (A, B): DiffResult<string>[] Parameters
- A: string
Actual string
- B: string
Expected string
Returns DiffResult<string>[]
Array of diff results.
Example: Usage
import { diffStr } from "@std/internal/diff-str";
import { assertEquals } from "@std/assert";
assertEquals(diffStr("Hello!", "Hello"), [
{
type: "removed",
value: "Hello!\n",
details: [
{ type: "common", value: "Hello" },
{ type: "removed", value: "!" },
{ type: "common", value: "\n" }
]
},
{
type: "added",
value: "Hello\n",
details: [
{ type: "common", value: "Hello" },
{ type: "common", value: "\n" }
]
}
]);- A: string
Renders the differences between the actual and expected strings. Partially inspired from https://github.com/kpdecker/jsdiff.