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

Function lines

packages/effect/src/TextDiff.ts:293–306  ·  view source on GitHub ↗
(before: string, after: string, options?: {
  /**
   * Largest number of inserted plus deleted items searched for in each
   * changed region. Common prefixes, suffixes and matching runs are free.
   * When a region needs more edits, the search splits it at the furthest
   * point it reached and continues on the rest, and a part that still cannot
   * be matched becomes a deletion followed by an insertion. The script stays
   * valid, and is minimal whenever the whole diff needs at most `maxEdits`
   * edits. For a finite cap, work is O((N + M) * (maxEdits + 1)).
   *
   * @default Infinity
   */
  readonly maxEdits?: number | undefined
})

Source from the content-addressed store, hash-verified

291 * @since 4.0.6
292 */
293export const lines = (before: string, after: string, options?: {
294 /**
295 * Largest number of inserted plus deleted items searched for in each
296 * changed region. Common prefixes, suffixes and matching runs are free.
297 * When a region needs more edits, the search splits it at the furthest
298 * point it reached and continues on the rest, and a part that still cannot
299 * be matched becomes a deletion followed by an insertion. The script stays
300 * valid, and is minimal whenever the whole diff needs at most `maxEdits`
301 * edits. For a finite cap, work is O((N + M) * (maxEdits + 1)).
302 *
303 * @default Infinity
304 */
305 readonly maxEdits?: number | undefined
306}): Array<Edit<string>> => diffStrings(splitLines(before), splitLines(after), options?.maxEdits)
307
308/**
309 * Computes a minimal code point edit script between two strings.

Callers 2

runPeerFunction · 0.50
spawnPeerFunction · 0.50

Calls 2

diffStringsFunction · 0.85
splitLinesFunction · 0.70

Tested by

no test coverage detected