This is a simple Luau module that performs a diff on two strings or two lists and returns a formatted diff string.
Differ = require("differ")
s1 = [[hello
...
to the
world]]
s2 = [[hello
...
*at* the
world]]
diff = Differ.diff(s1, s2)produces the output:
hello
...
- to the
+ *at* the
world
You can also diff tables:
Differ.diff({1,2,3,4,5}, {99,2,4,5,6})(when diffing tables, it is guaranteed that for matching chunks, .old and .new refer to
the same table, so chunk.old == chunk.new will succeed)