index.d.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /**
  2. * Copyright (c) Meta Platforms, Inc. and affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. import {CompareKeys} from 'pretty-format';
  8. /**
  9. * Class representing one diff tuple.
  10. * Attempts to look like a two-element array (which is what this used to be).
  11. * @param {number} op Operation, one of: DIFF_DELETE, DIFF_INSERT, DIFF_EQUAL.
  12. * @param {string} text Text to be deleted, inserted, or retained.
  13. * @constructor
  14. */
  15. export declare class Diff {
  16. 0: number;
  17. 1: string;
  18. constructor(op: number, text: string);
  19. }
  20. export declare function diff(
  21. a: any,
  22. b: any,
  23. options?: DiffOptions,
  24. ): string | null;
  25. /**
  26. * The data structure representing a diff is an array of tuples:
  27. * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
  28. * which means: delete 'Hello', add 'Goodbye' and keep ' world.'
  29. */
  30. export declare var DIFF_DELETE: number;
  31. export declare var DIFF_EQUAL: number;
  32. export declare var DIFF_INSERT: number;
  33. export declare const diffLinesRaw: (
  34. aLines: Array<string>,
  35. bLines: Array<string>,
  36. ) => Array<Diff>;
  37. export declare const diffLinesUnified: (
  38. aLines: Array<string>,
  39. bLines: Array<string>,
  40. options?: DiffOptions,
  41. ) => string;
  42. export declare const diffLinesUnified2: (
  43. aLinesDisplay: Array<string>,
  44. bLinesDisplay: Array<string>,
  45. aLinesCompare: Array<string>,
  46. bLinesCompare: Array<string>,
  47. options?: DiffOptions,
  48. ) => string;
  49. export declare type DiffOptions = {
  50. aAnnotation?: string;
  51. aColor?: DiffOptionsColor;
  52. aIndicator?: string;
  53. bAnnotation?: string;
  54. bColor?: DiffOptionsColor;
  55. bIndicator?: string;
  56. changeColor?: DiffOptionsColor;
  57. changeLineTrailingSpaceColor?: DiffOptionsColor;
  58. commonColor?: DiffOptionsColor;
  59. commonIndicator?: string;
  60. commonLineTrailingSpaceColor?: DiffOptionsColor;
  61. contextLines?: number;
  62. emptyFirstOrLastLinePlaceholder?: string;
  63. expand?: boolean;
  64. includeChangeCounts?: boolean;
  65. omitAnnotationLines?: boolean;
  66. patchColor?: DiffOptionsColor;
  67. compareKeys?: CompareKeys;
  68. };
  69. export declare type DiffOptionsColor = (arg: string) => string;
  70. export declare const diffStringsRaw: (
  71. a: string,
  72. b: string,
  73. cleanup: boolean,
  74. ) => Array<Diff>;
  75. export declare const diffStringsUnified: (
  76. a: string,
  77. b: string,
  78. options?: DiffOptions,
  79. ) => string;
  80. export {};