UNPKG

2.23 kBTypeScriptView Raw
1/**
2 * Diff Match and Patch
3 * Copyright 2018 The diff-match-patch Authors.
4 * https://github.com/google/diff-match-patch
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18/**
19 * @fileoverview Computes the difference between two texts to create a patch.
20 * Applies the patch onto another text, allowing for errors.
21 * @author fraser@google.com (Neil Fraser)
22 */
23/**
24 * CHANGES by pedrottimark to diff_match_patch_uncompressed.ts file:
25 *
26 * 1. Delete anything not needed to use diff_cleanupSemantic method
27 * 2. Convert from prototype properties to var declarations
28 * 3. Convert Diff to class from constructor and prototype
29 * 4. Add type annotations for arguments and return values
30 * 5. Add exports
31 */
32/**
33 * The data structure representing a diff is an array of tuples:
34 * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
35 * which means: delete 'Hello', add 'Goodbye' and keep ' world.'
36 */
37declare var DIFF_DELETE: number;
38declare var DIFF_INSERT: number;
39declare var DIFF_EQUAL: number;
40/**
41 * Class representing one diff tuple.
42 * Attempts to look like a two-element array (which is what this used to be).
43 * @param {number} op Operation, one of: DIFF_DELETE, DIFF_INSERT, DIFF_EQUAL.
44 * @param {string} text Text to be deleted, inserted, or retained.
45 * @constructor
46 */
47declare class Diff {
48 0: number;
49 1: string;
50 constructor(op: number, text: string);
51}
52/**
53 * Reduce the number of edits by eliminating semantically trivial equalities.
54 * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
55 */
56declare var diff_cleanupSemantic: (diffs: Array<Diff>) => void;
57export { Diff, DIFF_EQUAL, DIFF_DELETE, DIFF_INSERT, diff_cleanupSemantic as cleanupSemantic, };