MCPcopy Create free account
hub / github.com/Effect-TS/effect / diffWith

Function diffWith

packages/effect/src/TextDiff.ts:197–215  ·  view source on GitHub ↗
(isEquivalent: (self: A, that: A) => boolean)

Source from the content-addressed store, hash-verified

195 * @since 4.0.6
196 */
197export const diffWith = <A>(isEquivalent: (self: A, that: A) => boolean) =>
198(
199 before: ReadonlyArray<A>,
200 after: ReadonlyArray<A>,
201 options?: {
202 /**
203 * Largest number of inserted plus deleted items searched for in each
204 * changed region. Common prefixes, suffixes and matching runs are free.
205 * When a region needs more edits, the search splits it at the furthest
206 * point it reached and continues on the rest, and a part that still cannot
207 * be matched becomes a deletion followed by an insertion. The script stays
208 * valid, and is minimal whenever the whole diff needs at most `maxEdits`
209 * edits. For a finite cap, work is O((N + M) * (maxEdits + 1)).
210 *
211 * @default Infinity
212 */
213 readonly maxEdits?: number | undefined
214 }
215): Array<Edit<A>> => editScript(before, after, (i, j) => isEquivalent(before[i], after[j]), options?.maxEdits)
216
217/**
218 * Computes a minimal edit script between two arrays, comparing items with

Callers 1

diffFunction · 0.85

Calls 2

editScriptFunction · 0.85
isEquivalentFunction · 0.85

Tested by

no test coverage detected