jest-diff

  • Version 27.3.1
  • Published
  • 85.7 kB
  • 4 dependencies
  • MIT license

Install

npm i jest-diff
yarn add jest-diff
pnpm add jest-diff

Overview

Display differences clearly so people can review changes confidently.

Index

Variables

variable DIFF_DELETE

var DIFF_DELETE: number;
  • The data structure representing a diff is an array of tuples: [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']] which means: delete 'Hello', add 'Goodbye' and keep ' world.'

variable DIFF_EQUAL

var DIFF_EQUAL: number;

    variable DIFF_INSERT

    var DIFF_INSERT: number;

      Functions

      function diff

      diff: (a: any, b: any, options?: DiffOptions) => string | null;

        function diffLinesRaw

        diffLinesRaw: (aLines: Array<string>, bLines: Array<string>) => Array<Diff>;

          function diffLinesUnified

          diffLinesUnified: (
          aLines: Array<string>,
          bLines: Array<string>,
          options?: DiffOptions | undefined
          ) => string;

            function diffLinesUnified2

            diffLinesUnified2: (
            aLinesDisplay: Array<string>,
            bLinesDisplay: Array<string>,
            aLinesCompare: Array<string>,
            bLinesCompare: Array<string>,
            options?: DiffOptions | undefined
            ) => string;

              function diffStringsRaw

              diffStringsRaw: (a: string, b: string, cleanup: boolean) => Array<Diff>;

                function diffStringsUnified

                diffStringsUnified: (
                a: string,
                b: string,
                options?: DiffOptions | undefined
                ) => string;

                  Classes

                  class Diff

                  class Diff {}
                  • Class representing one diff tuple. Attempts to look like a two-element array (which is what this used to be).

                    Parameter op

                    Operation, one of: DIFF_DELETE, DIFF_INSERT, DIFF_EQUAL.

                    Parameter text

                    Text to be deleted, inserted, or retained.

                  constructor

                  constructor(op: number, text: string);

                    property 0

                    0: number;

                      property 1

                      1: string;

                        Type Aliases

                        type DiffOptions

                        type DiffOptions = {
                        aAnnotation?: string;
                        aColor?: DiffOptionsColor;
                        aIndicator?: string;
                        bAnnotation?: string;
                        bColor?: DiffOptionsColor;
                        bIndicator?: string;
                        changeColor?: DiffOptionsColor;
                        changeLineTrailingSpaceColor?: DiffOptionsColor;
                        commonColor?: DiffOptionsColor;
                        commonIndicator?: string;
                        commonLineTrailingSpaceColor?: DiffOptionsColor;
                        contextLines?: number;
                        emptyFirstOrLastLinePlaceholder?: string;
                        expand?: boolean;
                        includeChangeCounts?: boolean;
                        omitAnnotationLines?: boolean;
                        patchColor?: DiffOptionsColor;
                        };

                          type DiffOptionsColor

                          type DiffOptionsColor = (arg: string) => string;
                          • Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

                            This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.

                          Package Files (5)

                          Dependencies (4)

                          Dev Dependencies (2)

                          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/jest-diff.

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