utils/diff
@ckeditor/ckeditor5-utils/src/diff
Filtering
Functions
-
diff( a, b, [ cmp ] ) → Array
Calculates the difference between two arrays or strings producing an array containing a list of changes necessary to transform input into output.
This 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.Parameters
a : Array | String
Input array or string.
b : Array | String
Output array or string.
[ cmp ] : function
Optional function used to compare array values, by default === is used.
Returns
Array
Array of changes.
Every day, we work hard to keep our documentation complete. Have you spotted an outdated information? Is something missing? Please report it via our issue tracker.