function

diff.arrays

function arrays<T>(
oldArray: readonly T[],
newArray: readonly T[],
options?: Options & { maxEditLength: undefined }
): Change<T[]>[];

Compare two arrays element by element, with ===.

@returns

The changes, or undefined if there are more than maxEditLength edits

function arrays<T>(
oldArray: readonly T[],
newArray: readonly T[],
options?: Options
): undefined | Change<T[]>[];

Compare two arrays element by element, with ===.

@returns

The changes, or undefined if there are more than maxEditLength edits

Referenced types

interface Options

  • maxEditLength?: number

    Return undefined when the diff adds and removes more than this many tokens in total. An integer from 0, or Infinity.

interface Change<T = string>

A run of tokens that were kept, removed or added.

  • added: boolean

    The run is only in the new input.

  • count: number

    The number of tokens (lines, words, characters or elements) in value.

  • removed: boolean

    The run is only in the old input.

  • value: T

    The tokens of the run: joined for text, an array for arrays.