diff

  • Version 8.0.2
  • Published
  • 492 kB
  • No dependencies
  • BSD-3-Clause license

Install

npm i diff
yarn add diff
pnpm add diff

Overview

A JavaScript text diff implementation.

Index

Variables

variable arrayDiff

const arrayDiff: ArrayDiff<unknown>;

    variable characterDiff

    const characterDiff: CharacterDiff;

      variable cssDiff

      const cssDiff: CssDiff;

        variable jsonDiff

        const jsonDiff: JsonDiff;

          variable lineDiff

          const lineDiff: LineDiff;

            variable sentenceDiff

            const sentenceDiff: SentenceDiff;

              variable wordDiff

              const wordDiff: WordDiff;

                variable wordsWithSpaceDiff

                const wordsWithSpaceDiff: WordsWithSpaceDiff;

                  Functions

                  function applyPatch

                  applyPatch: (
                  source: string,
                  patch: string | StructuredPatch | [StructuredPatch],
                  options?: ApplyPatchOptions
                  ) => string | false;
                  • attempts to apply a unified diff patch.

                    Hunks are applied first to last. applyPatch first tries to apply the first hunk at the line number specified in the hunk header, and with all context lines matching exactly. If that fails, it tries scanning backwards and forwards, one line at a time, to find a place to apply the hunk where the context lines match exactly. If that still fails, and fuzzFactor is greater than zero, it increments the maximum number of mismatches (missing, extra, or changed context lines) that there can be between the hunk context and a region where we are trying to apply the patch such that the hunk will still be considered to match. Regardless of fuzzFactor, lines to be deleted in the hunk *must* be present for a hunk to match, and the context lines *immediately* before and after an insertion must match exactly.

                    Once a hunk is successfully fitted, the process begins again with the next hunk. Regardless of fuzzFactor, later hunks must be applied later in the file than earlier hunks.

                    If a hunk cannot be successfully fitted *anywhere* with fewer than fuzzFactor mismatches, applyPatch fails and returns false.

                    If a hunk is successfully fitted but not at the line number specified by the hunk header, all subsequent hunks have their target line number adjusted accordingly. (e.g. if the first hunk is applied 10 lines below where the hunk header said it should fit, applyPatch will *start* looking for somewhere to apply the second hunk 10 lines below where its hunk header says it goes.)

                    If the patch was applied successfully, returns a string containing the patched text. If the patch could not be applied (because some hunks in the patch couldn't be fitted to the text in source), applyPatch returns false.

                    Parameter patch

                    a string diff or the output from the parsePatch or structuredPatch methods.

                  function applyPatches

                  applyPatches: (
                  uniDiff: string | StructuredPatch[],
                  options: ApplyPatchesOptions
                  ) => void;
                  • applies one or more patches.

                    patch may be either an array of structured patch objects, or a string representing a patch in unified diff format (which may patch one or more files).

                    This method will iterate over the contents of the patch and apply to data provided through callbacks. The general flow for each patch index is:

                    - options.loadFile(index, callback) is called. The caller should then load the contents of the file and then pass that to the callback(err, data) callback. Passing an err will terminate further patch execution. - options.patched(index, content, callback) is called once the patch has been applied. content will be the return value from applyPatch. When it's ready, the caller should call callback(err) callback. Passing an err will terminate further patch execution.

                    Once all patches have been applied or an error occurs, the options.complete(err) callback is made.

                  function canonicalize

                  canonicalize: (
                  obj: any,
                  stack: Array<any> | null,
                  replacementStack: Array<any> | null,
                  replacer: (k: string, v: any) => any,
                  key?: string
                  ) => any;

                    function convertChangesToDMP

                    convertChangesToDMP: <ValueT>(
                    changes: ChangeObject<ValueT>[]
                    ) => [DmpOperation, ValueT][];
                    • converts a list of change objects to the format returned by Google's [diff-match-patch](https://github.com/google/diff-match-patch) library

                    function convertChangesToXML

                    convertChangesToXML: (changes: ChangeObject<string>[]) => string;
                    • converts a list of change objects to a serialized XML format

                    function createPatch

                    createPatch: {
                    (
                    fileName: string,
                    oldStr: string,
                    newStr: string,
                    oldHeader: string | undefined,
                    newHeader: string | undefined,
                    options: CreatePatchCallbackNonabortable
                    ): undefined;
                    (
                    fileName: string,
                    oldStr: string,
                    newStr: string,
                    oldHeader: string,
                    newHeader: string,
                    options: CreatePatchOptionsAbortable & CreatePatchCallbackOptionAbortable
                    ): undefined;
                    (
                    fileName: string,
                    oldStr: string,
                    newStr: string,
                    oldHeader: string,
                    newHeader: string,
                    options: CreatePatchOptionsNonabortable &
                    CreatePatchCallbackOptionNonabortable
                    ): undefined;
                    (
                    fileName: string,
                    oldStr: string,
                    newStr: string,
                    oldHeader: string,
                    newHeader: string,
                    options: CreatePatchOptionsAbortable
                    ): string;
                    (
                    fileName: string,
                    oldStr: string,
                    newStr: string,
                    oldHeader?: string,
                    newHeader?: string,
                    options?: CreatePatchOptionsNonabortable
                    ): string;
                    };
                    • creates a unified diff patch.

                      Just like createTwoFilesPatch, but with oldFileName being equal to newFileName.

                      Parameter fileName

                      String to be output in the filename section of the patch

                      Parameter oldStr

                      Original string value

                      Parameter newStr

                      New string value

                      Parameter oldHeader

                      Optional additional information to include in the old file header.

                      Parameter newHeader

                      Optional additional information to include in the new file header.

                    function createTwoFilesPatch

                    createTwoFilesPatch: {
                    (
                    oldFileName: string,
                    newFileName: string,
                    oldStr: string,
                    newStr: string,
                    oldHeader: string | undefined,
                    newHeader: string | undefined,
                    options: CreatePatchCallbackNonabortable
                    ): undefined;
                    (
                    oldFileName: string,
                    newFileName: string,
                    oldStr: string,
                    newStr: string,
                    oldHeader: string,
                    newHeader: string,
                    options: CreatePatchOptionsAbortable & CreatePatchCallbackOptionAbortable
                    ): undefined;
                    (
                    oldFileName: string,
                    newFileName: string,
                    oldStr: string,
                    newStr: string,
                    oldHeader: string,
                    newHeader: string,
                    options: CreatePatchOptionsNonabortable &
                    CreatePatchCallbackOptionNonabortable
                    ): undefined;
                    (
                    oldFileName: string,
                    newFileName: string,
                    oldStr: string,
                    newStr: string,
                    oldHeader: string,
                    newHeader: string,
                    options: CreatePatchOptionsAbortable
                    ): string;
                    (
                    oldFileName: string,
                    newFileName: string,
                    oldStr: string,
                    newStr: string,
                    oldHeader?: string,
                    newHeader?: string,
                    options?: CreatePatchOptionsNonabortable
                    ): string;
                    };
                    • creates a unified diff patch by first computing a diff with diffLines and then serializing it to unified diff format.

                      Parameter oldFileName

                      String to be output in the filename section of the patch for the removals

                      Parameter newFileName

                      String to be output in the filename section of the patch for the additions

                      Parameter oldStr

                      Original string value

                      Parameter newStr

                      New string value

                      Parameter oldHeader

                      Optional additional information to include in the old file header.

                      Parameter newHeader

                      Optional additional information to include in the new file header.

                    function diffArrays

                    diffArrays: {
                    <T>(oldArr: T[], newArr: T[], options: DiffCallbackNonabortable<T[]>): undefined;
                    <T>(
                    oldArr: T[],
                    newArr: T[],
                    options: DiffArraysOptionsAbortable<T> & CallbackOptionAbortable<T[]>
                    ): undefined;
                    <T>(
                    oldArr: T[],
                    newArr: T[],
                    options: DiffArraysOptionsNonabortable<T> & CallbackOptionNonabortable<T[]>
                    ): undefined;
                    <T>(
                    oldArr: T[],
                    newArr: T[],
                    options: DiffArraysOptionsAbortable<T>
                    ): ChangeObject<T[]>[];
                    <T>(
                    oldArr: T[],
                    newArr: T[],
                    options?: DiffArraysOptionsNonabortable<T>
                    ): ChangeObject<T[]>[];
                    };
                    • diffs two arrays of tokens, comparing each item for strict equality (===).

                      Returns

                      a list of change objects.

                    function diffChars

                    diffChars: {
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffCallbackNonabortable<string>
                    ): undefined;
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffCharsOptionsAbortable & CallbackOptionAbortable<string>
                    ): undefined;
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffCharsOptionsNonabortable & CallbackOptionNonabortable<string>
                    ): undefined;
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffCharsOptionsAbortable
                    ): ChangeObject<string>[];
                    (
                    oldStr: string,
                    newStr: string,
                    options?: DiffCharsOptionsNonabortable
                    ): ChangeObject<string>[];
                    };
                    • diffs two blocks of text, treating each character as a token.

                      ("Characters" here means Unicode code points - the elements you get when you loop over a string with a for ... of ... loop.)

                      Returns

                      a list of change objects.

                    function diffCss

                    diffCss: {
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffCallbackNonabortable<string>
                    ): undefined;
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffCssOptionsAbortable & CallbackOptionAbortable<string>
                    ): undefined;
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffCssOptionsNonabortable & CallbackOptionNonabortable<string>
                    ): undefined;
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffCssOptionsAbortable
                    ): ChangeObject<string>[];
                    (
                    oldStr: string,
                    newStr: string,
                    options?: DiffCssOptionsNonabortable
                    ): ChangeObject<string>[];
                    };
                    • diffs two blocks of text, comparing CSS tokens.

                      Returns

                      a list of change objects.

                    function diffJson

                    diffJson: {
                    (
                    oldStr: string | object,
                    newStr: string | object,
                    options: DiffCallbackNonabortable<string>
                    ): undefined;
                    (
                    oldStr: string | object,
                    newStr: string | object,
                    options: DiffJsonOptionsAbortable & CallbackOptionAbortable<string>
                    ): undefined;
                    (
                    oldStr: string | object,
                    newStr: string | object,
                    options: DiffJsonOptionsNonabortable & CallbackOptionNonabortable<string>
                    ): undefined;
                    (
                    oldStr: string | object,
                    newStr: string | object,
                    options: DiffJsonOptionsAbortable
                    ): ChangeObject<string>[];
                    (
                    oldStr: string | object,
                    newStr: string | object,
                    options?: DiffJsonOptionsNonabortable
                    ): ChangeObject<string>[];
                    };
                    • diffs two JSON-serializable objects by first serializing them to prettily-formatted JSON and then treating each line of the JSON as a token. Object properties are ordered alphabetically in the serialized JSON, so the order of properties in the objects being compared doesn't affect the result.

                      Returns

                      a list of change objects.

                    function diffLines

                    diffLines: {
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffCallbackNonabortable<string>
                    ): undefined;
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffLinesOptionsAbortable & CallbackOptionAbortable<string>
                    ): undefined;
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffLinesOptionsNonabortable & CallbackOptionNonabortable<string>
                    ): undefined;
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffLinesOptionsAbortable
                    ): ChangeObject<string>[];
                    (
                    oldStr: string,
                    newStr: string,
                    options?: DiffLinesOptionsNonabortable
                    ): ChangeObject<string>[];
                    };
                    • diffs two blocks of text, treating each line as a token.

                      Returns

                      a list of change objects.

                    function diffSentences

                    diffSentences: {
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffCallbackNonabortable<string>
                    ): undefined;
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffSentencesOptionsAbortable & CallbackOptionAbortable<string>
                    ): undefined;
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffSentencesOptionsNonabortable &
                    CallbackOptionNonabortable<string>
                    ): undefined;
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffSentencesOptionsAbortable
                    ): ChangeObject<string>[];
                    (
                    oldStr: string,
                    newStr: string,
                    options?: DiffSentencesOptionsNonabortable
                    ): ChangeObject<string>[];
                    };
                    • diffs two blocks of text, treating each sentence, and the whitespace between each pair of sentences, as a token. The characters ., !, and ?, when followed by whitespace, are treated as marking the end of a sentence; nothing else besides the end of the string is considered to mark a sentence end.

                      (For more sophisticated detection of sentence breaks, including support for non-English punctuation, consider instead tokenizing with an [Intl.Segmenter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter) with granularity: 'sentence' and passing the result to diffArrays.)

                      Returns

                      a list of change objects.

                    function diffTrimmedLines

                    diffTrimmedLines: {
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffCallbackNonabortable<string>
                    ): undefined;
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffLinesOptionsAbortable & CallbackOptionAbortable<string>
                    ): undefined;
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffLinesOptionsNonabortable & CallbackOptionNonabortable<string>
                    ): undefined;
                    (
                    oldStr: string,
                    newStr: string,
                    options: DiffLinesOptionsAbortable
                    ): ChangeObject<string>[];
                    (
                    oldStr: string,
                    newStr: string,
                    options?: DiffLinesOptionsNonabortable
                    ): ChangeObject<string>[];
                    };

                      function diffWords

                      diffWords: {
                      (
                      oldStr: string,
                      newStr: string,
                      options: DiffCallbackNonabortable<string>
                      ): undefined;
                      (
                      oldStr: string,
                      newStr: string,
                      options: DiffWordsOptionsAbortable & CallbackOptionAbortable<string>
                      ): undefined;
                      (
                      oldStr: string,
                      newStr: string,
                      options: DiffWordsOptionsNonabortable & CallbackOptionNonabortable<string>
                      ): undefined;
                      (
                      oldStr: string,
                      newStr: string,
                      options: DiffWordsOptionsAbortable
                      ): ChangeObject<string>[];
                      (
                      oldStr: string,
                      newStr: string,
                      options?: DiffWordsOptionsNonabortable
                      ): ChangeObject<string>[];
                      };
                      • diffs two blocks of text, treating each word and each punctuation mark as a token. Whitespace is ignored when computing the diff (but preserved as far as possible in the final change objects).

                        Returns

                        a list of change objects.

                      function diffWordsWithSpace

                      diffWordsWithSpace: {
                      (
                      oldStr: string,
                      newStr: string,
                      options: DiffCallbackNonabortable<string>
                      ): undefined;
                      (
                      oldStr: string,
                      newStr: string,
                      options: DiffWordsOptionsAbortable & CallbackOptionAbortable<string>
                      ): undefined;
                      (
                      oldStr: string,
                      newStr: string,
                      options: DiffWordsOptionsNonabortable & CallbackOptionNonabortable<string>
                      ): undefined;
                      (
                      oldStr: string,
                      newStr: string,
                      options: DiffWordsOptionsAbortable
                      ): ChangeObject<string>[];
                      (
                      oldStr: string,
                      newStr: string,
                      options?: DiffWordsOptionsNonabortable
                      ): ChangeObject<string>[];
                      };
                      • diffs two blocks of text, treating each word, punctuation mark, newline, or run of (non-newline) whitespace as a token.

                        Returns

                        a list of change objects

                      function formatPatch

                      formatPatch: (patch: StructuredPatch | StructuredPatch[]) => string;
                      • creates a unified diff patch.

                        Parameter patch

                        either a single structured patch object (as returned by structuredPatch) or an array of them (as returned by parsePatch)

                      function parsePatch

                      parsePatch: (uniDiff: string) => StructuredPatch[];
                      • Parses a patch into structured data, in the same structure returned by structuredPatch.

                        a JSON object representation of the a patch, suitable for use with the applyPatch method.

                      function reversePatch

                      reversePatch: {
                      (structuredPatch: StructuredPatch): StructuredPatch;
                      (structuredPatch: StructuredPatch[]): StructuredPatch[];
                      (structuredPatch: StructuredPatch | StructuredPatch[]):
                      | StructuredPatch
                      | StructuredPatch[];
                      };
                      • Parameter patch

                        either a single structured patch object (as returned by structuredPatch) or an array of them (as returned by parsePatch).

                        Returns

                        a new structured patch which when applied will undo the original patch.

                      function structuredPatch

                      structuredPatch: {
                      (
                      oldFileName: string,
                      newFileName: string,
                      oldStr: string,
                      newStr: string,
                      oldHeader: string | undefined,
                      newHeader: string | undefined,
                      options: StructuredPatchCallbackNonabortable
                      ): undefined;
                      (
                      oldFileName: string,
                      newFileName: string,
                      oldStr: string,
                      newStr: string,
                      oldHeader: string,
                      newHeader: string,
                      options: StructuredPatchOptionsAbortable &
                      StructuredPatchCallbackOptionAbortable
                      ): undefined;
                      (
                      oldFileName: string,
                      newFileName: string,
                      oldStr: string,
                      newStr: string,
                      oldHeader: string,
                      newHeader: string,
                      options: StructuredPatchOptionsNonabortable &
                      StructuredPatchCallbackOptionNonabortable
                      ): undefined;
                      (
                      oldFileName: string,
                      newFileName: string,
                      oldStr: string,
                      newStr: string,
                      oldHeader: string,
                      newHeader: string,
                      options: StructuredPatchOptionsAbortable
                      ): StructuredPatch;
                      (
                      oldFileName: string,
                      newFileName: string,
                      oldStr: string,
                      newStr: string,
                      oldHeader?: string,
                      newHeader?: string,
                      options?: StructuredPatchOptionsNonabortable
                      ): StructuredPatch;
                      };
                      • returns an object with an array of hunk objects.

                        This method is similar to createTwoFilesPatch, but returns a data structure suitable for further processing.

                        Parameter oldFileName

                        String to be output in the filename section of the patch for the removals

                        Parameter newFileName

                        String to be output in the filename section of the patch for the additions

                        Parameter oldStr

                        Original string value

                        Parameter newStr

                        New string value

                        Parameter oldHeader

                        Optional additional information to include in the old file header.

                        Parameter newHeader

                        Optional additional information to include in the new file header.

                      Classes

                      class Diff

                      class Diff<
                      TokenT,
                      ValueT extends Iterable<TokenT> = Iterable<TokenT>,
                      InputValueT = ValueT
                      > {}

                        property useLongestToken

                        readonly useLongestToken: boolean;

                          method castInput

                          castInput: (value: InputValueT, options: AllDiffOptions) => ValueT;

                            method diff

                            diff: {
                            (
                            oldStr: InputValueT,
                            newStr: InputValueT,
                            options: DiffCallbackNonabortable<ValueT>
                            ): undefined;
                            (
                            oldStr: InputValueT,
                            newStr: InputValueT,
                            options: DiffArraysOptions<unknown> &
                            DiffCharsOptions &
                            DiffWordsOptions &
                            DiffLinesOptions &
                            DiffJsonOptions &
                            AbortableDiffOptions &
                            CallbackOptionAbortable<ValueT>
                            ): undefined;
                            (
                            oldStr: InputValueT,
                            newStr: InputValueT,
                            options: DiffArraysOptions<unknown> &
                            DiffCharsOptions &
                            DiffWordsOptions &
                            DiffLinesOptions &
                            DiffJsonOptions &
                            CallbackOptionNonabortable<ValueT>
                            ): undefined;
                            (
                            oldStr: InputValueT,
                            newStr: InputValueT,
                            options: DiffArraysOptions<unknown> &
                            DiffCharsOptions &
                            DiffWordsOptions &
                            DiffLinesOptions &
                            DiffJsonOptions &
                            AbortableDiffOptions
                            ): ChangeObject<ValueT>[];
                            (
                            oldStr: InputValueT,
                            newStr: InputValueT,
                            options?: AllDiffOptions
                            ): ChangeObject<ValueT>[];
                            };

                              method equals

                              equals: (left: TokenT, right: TokenT, options: AllDiffOptions) => boolean;

                                method join

                                join: (chars: TokenT[]) => ValueT;

                                  method postProcess

                                  postProcess: (
                                  changeObjects: ChangeObject<ValueT>[],
                                  options: AllDiffOptions
                                  ) => ChangeObject<ValueT>[];

                                    method removeEmpty

                                    removeEmpty: (array: TokenT[]) => TokenT[];

                                      method tokenize

                                      tokenize: (value: ValueT, options: AllDiffOptions) => TokenT[];

                                        Interfaces

                                        interface ApplyPatchesOptions

                                        interface ApplyPatchesOptions extends ApplyPatchOptions {}

                                          property complete

                                          complete: (err?: any) => void;

                                            property loadFile

                                            loadFile: (
                                            index: StructuredPatch,
                                            callback: (err: any, data: string) => void
                                            ) => void;

                                              property patched

                                              patched: (
                                              index: StructuredPatch,
                                              content: string | false,
                                              callback: (err: any) => void
                                              ) => void;

                                                interface ApplyPatchOptions

                                                interface ApplyPatchOptions {}

                                                  property autoConvertLineEndings

                                                  autoConvertLineEndings?: boolean;
                                                  • If true, and if the file to be patched consistently uses different line endings to the patch (i.e. either the file always uses Unix line endings while the patch uses Windows ones, or vice versa), then applyPatch will behave as if the line endings in the patch were the same as those in the source file. (If false, the patch will usually fail to apply in such circumstances since lines deleted in the patch won't be considered to match those in the source file.) true

                                                  property compareLine

                                                  compareLine?: (
                                                  lineNumber: number,
                                                  line: string,
                                                  operation: string,
                                                  patchContent: string
                                                  ) => boolean;
                                                  • Callback used to compare to given lines to determine if they should be considered equal when patching. Defaults to strict equality but may be overridden to provide fuzzier comparison. Should return false if the lines should be rejected.

                                                  property fuzzFactor

                                                  fuzzFactor?: number;
                                                  • Maximum Levenshtein distance (in lines deleted, added, or subtituted) between the context shown in a patch hunk and the lines found in the file. 0

                                                  interface ChangeObject

                                                  interface ChangeObject<ValueT> {}

                                                    property added

                                                    added: boolean;
                                                    • true if the value was inserted into the new string, otherwise false

                                                    property count

                                                    count: number;
                                                    • How many tokens (e.g. chars for diffChars, lines for diffLines) the value in the change object consists of

                                                    property removed

                                                    removed: boolean;
                                                    • true if the value was removed from the old string, otherwise false

                                                    property value

                                                    value: ValueT;
                                                    • The concatenated content of all the tokens represented by this change object - i.e. generally the text that is either added, deleted, or common, as a single string. In cases where tokens are considered common but are non-identical (e.g. because an option like ignoreCase or a custom comparator was used), the value from the *new* string will be provided here.

                                                    interface CreatePatchOptionsNonabortable

                                                    interface CreatePatchOptionsNonabortable
                                                    extends Pick<
                                                    DiffLinesOptionsNonabortable,
                                                    'ignoreWhitespace' | 'stripTrailingCr'
                                                    > {}

                                                      property callback

                                                      callback?: CreatePatchCallbackNonabortable;

                                                        property context

                                                        context?: number;

                                                          interface DiffArraysOptionsNonabortable

                                                          interface DiffArraysOptionsNonabortable<T> extends DiffArraysOptions<T> {}

                                                            property callback

                                                            callback?: DiffCallbackNonabortable<T[]>;
                                                            • If provided, the diff will be computed in async mode to avoid blocking the event loop while the diff is calculated. The value of the callback option should be a function and will be passed the computed diff or patch as its first argument.

                                                            interface DiffCharsOptionsNonabortable

                                                            interface DiffCharsOptionsNonabortable extends DiffCharsOptions {}

                                                              property callback

                                                              callback?: DiffCallbackNonabortable<string>;
                                                              • If provided, the diff will be computed in async mode to avoid blocking the event loop while the diff is calculated. The value of the callback option should be a function and will be passed the computed diff or patch as its first argument.

                                                              interface DiffCssOptionsNonabortable

                                                              interface DiffCssOptionsNonabortable extends DiffCssOptions {}

                                                                property callback

                                                                callback?: DiffCallbackNonabortable<string>;
                                                                • If provided, the diff will be computed in async mode to avoid blocking the event loop while the diff is calculated. The value of the callback option should be a function and will be passed the computed diff or patch as its first argument.

                                                                interface DiffJsonOptionsNonabortable

                                                                interface DiffJsonOptionsNonabortable extends DiffJsonOptions {}

                                                                  property callback

                                                                  callback?: DiffCallbackNonabortable<string>;
                                                                  • If provided, the diff will be computed in async mode to avoid blocking the event loop while the diff is calculated. The value of the callback option should be a function and will be passed the computed diff or patch as its first argument.

                                                                  interface DiffLinesOptionsNonabortable

                                                                  interface DiffLinesOptionsNonabortable extends DiffLinesOptions {}

                                                                    property callback

                                                                    callback?: DiffCallbackNonabortable<string>;
                                                                    • If provided, the diff will be computed in async mode to avoid blocking the event loop while the diff is calculated. The value of the callback option should be a function and will be passed the computed diff or patch as its first argument.

                                                                    interface DiffSentencesOptionsNonabortable

                                                                    interface DiffSentencesOptionsNonabortable extends DiffSentencesOptions {}

                                                                      property callback

                                                                      callback?: DiffCallbackNonabortable<string>;
                                                                      • If provided, the diff will be computed in async mode to avoid blocking the event loop while the diff is calculated. The value of the callback option should be a function and will be passed the computed diff or patch as its first argument.

                                                                      interface DiffWordsOptionsNonabortable

                                                                      interface DiffWordsOptionsNonabortable extends DiffWordsOptions {}

                                                                        property callback

                                                                        callback?: DiffCallbackNonabortable<string>;
                                                                        • If provided, the diff will be computed in async mode to avoid blocking the event loop while the diff is calculated. The value of the callback option should be a function and will be passed the computed diff or patch as its first argument.

                                                                        interface StructuredPatch

                                                                        interface StructuredPatch {}

                                                                          property hunks

                                                                          hunks: StructuredPatchHunk[];

                                                                            property index

                                                                            index?: string;

                                                                              property newFileName

                                                                              newFileName: string;

                                                                                property newHeader

                                                                                newHeader: string | undefined;

                                                                                  property oldFileName

                                                                                  oldFileName: string;

                                                                                    property oldHeader

                                                                                    oldHeader: string | undefined;

                                                                                      interface StructuredPatchHunk

                                                                                      interface StructuredPatchHunk {}

                                                                                        property lines

                                                                                        lines: string[];

                                                                                          property newLines

                                                                                          newLines: number;

                                                                                            property newStart

                                                                                            newStart: number;

                                                                                              property oldLines

                                                                                              oldLines: number;

                                                                                                property oldStart

                                                                                                oldStart: number;

                                                                                                  interface StructuredPatchOptionsNonabortable

                                                                                                  interface StructuredPatchOptionsNonabortable
                                                                                                  extends Pick<
                                                                                                  DiffLinesOptionsNonabortable,
                                                                                                  'ignoreWhitespace' | 'stripTrailingCr'
                                                                                                  > {}

                                                                                                    property callback

                                                                                                    callback?: StructuredPatchCallbackNonabortable;

                                                                                                      property context

                                                                                                      context?: number;

                                                                                                        Type Aliases

                                                                                                        type Change

                                                                                                        type Change = ChangeObject<string>;

                                                                                                          type CreatePatchOptionsAbortable

                                                                                                          type CreatePatchOptionsAbortable = _CreatePatchOptionsAbortable &
                                                                                                          AbortableDiffOptions;

                                                                                                            type DiffArraysOptionsAbortable

                                                                                                            type DiffArraysOptionsAbortable<T> = DiffArraysOptions<T> &
                                                                                                            AbortableDiffOptions &
                                                                                                            Partial<CallbackOptionAbortable<T[]>>;

                                                                                                              type DiffCharsOptionsAbortable

                                                                                                              type DiffCharsOptionsAbortable = DiffCharsOptions &
                                                                                                              AbortableDiffOptions &
                                                                                                              Partial<CallbackOptionAbortable<string>>;

                                                                                                                type DiffCssOptionsAbortable

                                                                                                                type DiffCssOptionsAbortable = DiffJsonOptions &
                                                                                                                AbortableDiffOptions &
                                                                                                                Partial<CallbackOptionAbortable<string>>;

                                                                                                                  type DiffJsonOptionsAbortable

                                                                                                                  type DiffJsonOptionsAbortable = DiffJsonOptions &
                                                                                                                  AbortableDiffOptions &
                                                                                                                  Partial<CallbackOptionAbortable<string>>;

                                                                                                                    type DiffLinesOptionsAbortable

                                                                                                                    type DiffLinesOptionsAbortable = DiffLinesOptions &
                                                                                                                    AbortableDiffOptions &
                                                                                                                    Partial<CallbackOptionAbortable<string>>;

                                                                                                                      type DiffSentencesOptionsAbortable

                                                                                                                      type DiffSentencesOptionsAbortable = DiffSentencesOptions &
                                                                                                                      AbortableDiffOptions &
                                                                                                                      Partial<CallbackOptionAbortable<string>>;

                                                                                                                        type DiffWordsOptionsAbortable

                                                                                                                        type DiffWordsOptionsAbortable = DiffWordsOptions &
                                                                                                                        AbortableDiffOptions &
                                                                                                                        Partial<CallbackOptionAbortable<string>>;

                                                                                                                          type StructuredPatchOptionsAbortable

                                                                                                                          type StructuredPatchOptionsAbortable = _StructuredPatchOptionsAbortable &
                                                                                                                          AbortableDiffOptions;

                                                                                                                            Package Files (16)

                                                                                                                            Dependencies (0)

                                                                                                                            No dependencies.

                                                                                                                            Dev Dependencies (26)

                                                                                                                            Peer Dependencies (0)

                                                                                                                            No peer dependencies.

                                                                                                                            Badge

                                                                                                                            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/diff.

                                                                                                                            • Markdown
                                                                                                                              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/diff)
                                                                                                                            • HTML
                                                                                                                              <a href="https://www.jsdocs.io/package/diff"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>