Type Editor / @type-editor/changeset / simplify-changes / simplifyChanges
Function: simplifyChanges()
ts
function simplifyChanges(changes, doc): Change<any>[];Defined in: simplify-changes.ts:25
Simplifies a set of changes for presentation.
This function makes changes more readable by expanding insertions and deletions that occur within the same word to cover entire words. This prevents confusing partial-word changes while maintaining accuracy.
The algorithm:
- Groups nearby changes (within MAX_SIMPLIFY_DISTANCE)
- For mixed insertions/deletions in a group, expands to word boundaries
- Preserves single-character replacements as-is
- Merges adjacent changes when appropriate
Parameters
| Parameter | Type | Description |
|---|---|---|
changes | readonly Change<any>[] | The array of changes to simplify. |
doc | Node_2 | The document node (new version) to analyze. |
Returns
Change<any>[]
A new array of simplified changes.