Skip to content

Type Editor


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:

  1. Groups nearby changes (within MAX_SIMPLIFY_DISTANCE)
  2. For mixed insertions/deletions in a group, expands to word boundaries
  3. Preserves single-character replacements as-is
  4. Merges adjacent changes when appropriate

Parameters

ParameterTypeDescription
changesreadonly Change<any>[]The array of changes to simplify.
docNode_2The document node (new version) to analyze.

Returns

Change<any>[]

A new array of simplified changes.