# utils/diff

module

<a id="constants">

## Constants

<a id="constant-diff">

### `diff: Diff`

Calculates the difference between two arrays or strings producing an array containing a list of changes necessary to transform input into output.

```typescript
diff( 'aba', 'acca' ); // [ 'equal', 'insert', 'insert', 'delete', 'equal' ]
```

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 to [`fastDiff()`](module_utils_fastdiff.md#function-fastDiff) when detecting such a scenario. The return formats of both functions are identical.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/diff.ts#L38)

<a id="type-definitions">

## Type Definitions

<a id="typedef-Diff">

### `Diff`

<a id="typedef-DiffResult">

### `DiffResult`

---

Full index of the CKEditor 5 API reference: [llms.txt](llms.txt)
