Compare texts line by line and find differences.
import { diff } from 'toolmetry';| Function | Parameters | Returns | Description |
|---|---|---|---|
diffCheck | oldText: string, newText: string | { lines, stats } | Compare two strings line by line |
diffUnified | oldText: string, newText: string, oldLabel?, newLabel? | string | Generate unified diff string |
diffIsSame | a: string, b: string | boolean | Check if two strings are identical |
import { diffCheck } from 'toolmetry';
const result = diffCheck('Hello\nWorld', 'Hello\nEarth');
// { lines: [...], stats: { added: 1, removed: 1, unchanged: 1 } }import { diffUnified } from 'toolmetry';
const unified = diffUnified('Hello\nWorld', 'Hello\nEarth');
// "--- original\n+++ modified\n Hello\n- World\n+ Earth"import { diffIsSame } from 'toolmetry';
diffIsSame('hello', 'hello'); // true
diffIsSame('hello', 'world'); // false