Function signature
Example
Parameters
Buffer
required
The original document as a Node.js
Buffer. Read from disk with fs.readFile or receive from any source that returns binary data.Buffer
required
The revised document as a Node.js
Buffer.CompareOptions
Optional comparison configuration.
Return value
Promise<CompareResult>
Buffer
required
The resulting DOCX file with track-change markup. Write to disk or return as a response body.
CompareStats
required
Counts of changes detected in the comparison.
'wmlcomparer' | 'atomizer'
required
Which engine was used to produce the output.
'rebuild' | 'inplace'
The reconstruction mode requested via options. Present for atomizer outputs.
'rebuild' | 'inplace'
The reconstruction mode that was actually used to produce the output. May differ from
reconstructionModeRequested if the atomizer fell back. Present for atomizer outputs.'round_trip_safety_check_failed'
Why the requested reconstruction mode could not be used. Present only when the atomizer falls back from
'inplace' to 'rebuild'.ReconstructionFallbackDiagnostics
Detailed safety-check diagnostics for the fallback decision. Present only when the atomizer falls back. See Comparison options reference for the full type.
Removed engine
The'diffmatch' engine has been removed from the public API. Passing engine: 'diffmatch' throws:
'atomizer' or 'auto' instead.
Detecting fallback
To detect when the atomizer falls back from'inplace' to 'rebuild' mode (which may affect table structure fidelity), check result.reconstructionModeUsed:
fail_on_rebuild_fallback option in the MCP save tool to surface this as an error automatically.
