utils/diff
module
Constants
module:utils/diff~diffCalculates the difference between two arrays or strings producing an array containing a list of changes necessary to transform input into output.
diff( 'aba', 'acca' ); // [ 'equal', 'insert', 'insert', 'delete', 'equal' ]Copy codeThis function is based on the "O(NP) Sequence Comparison Algorithm" by Sun Wu, Udi Manber, Gene Myers, Webb Miller. Unfortunately, while it gives the most precise results, its to complex for longer strings/arrow (above 200 items). Therefore,
diff()automatically switches tofastDiff()when detecting such a scenario. The return formats of both functions are identical.
Type Definitions
module:utils/diff~Diffmodule:utils/diff~DiffResult