@unicom-cloud/utils 0.1.20 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -70
- package/nzh/src/index.js +1 -1
- package/package.json +1 -1
- package/tree/search/index.js +95 -66
- package/types/index.d.ts +1 -30
- package/types/is/index.d.ts +16 -16
- package/types/tree/search/index.d.ts +11 -1
- package/types/turbo-stream/src/shared.d.ts +3 -3
- package/types/version/index.d.ts +2 -0
- package/version/index.js +5 -0
- package/version.js +5 -0
- package/diff/index.js +0 -7
- package/diff/src/diff.d.ts +0 -21
- package/diff/src/diff.js +0 -381
- package/diff.js +0 -7
- package/types/diff/index.d.ts +0 -2
- package/types/diff/src/diff.d.ts +0 -40
package/index.js
CHANGED
|
@@ -1,72 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as e from "./date/index.js";
|
|
3
|
-
import * as r from "./is/index.js";
|
|
4
|
-
import * as t from "./math/index.js";
|
|
5
|
-
import * as a from "./snapdom/index.js";
|
|
6
|
-
import * as s from "./tree/index.js";
|
|
7
|
-
import * as i from "./turbo-stream/index.js";
|
|
8
|
-
import * as m from "./ui-color/index.js";
|
|
9
|
-
import * as p from "./url-toolkit/index.js";
|
|
10
|
-
import { default as u } from "./case-name/index.js";
|
|
11
|
-
import { default as C } from "./class-name/index.js";
|
|
12
|
-
import { default as b } from "./clipboard-copy/index.js";
|
|
13
|
-
import { default as k, getContentDispositionFromHeader as y, getContentDispositionParametersFilenameFromHeader as T, getContentDispositionParametersFromHeader as g } from "./content-disposition/index.js";
|
|
14
|
-
import { splitCookiesString as D } from "./cookie/index.js";
|
|
15
|
-
import { default as S } from "./decimal/decimal.js";
|
|
16
|
-
import { default as j } from "./diff/src/diff.js";
|
|
17
|
-
import { Emitter as L } from "./emitter/src/index.js";
|
|
18
|
-
import { fileToURL as P } from "./file/fileToURL.js";
|
|
19
|
-
import { saveAs as E } from "./file/saveAs.js";
|
|
20
|
-
import * as f from "./filesize/src/constants.js";
|
|
21
|
-
import { filesize as R, partial as U } from "./filesize/src/filesize.js";
|
|
22
|
-
import { default as $ } from "./invariant/index.js";
|
|
23
|
-
import { default as w } from "./js-cookie/src/api.js";
|
|
24
|
-
import * as n from "./lunar/lib/index.js";
|
|
25
|
-
import { default as G } from "./md5/index.js";
|
|
26
|
-
import { default as J } from "./normalize-wheel/index.js";
|
|
27
|
-
import { default as O } from "./number-to-chinese/index.js";
|
|
28
|
-
import { default as V } from "./nzh/nzh.js";
|
|
29
|
-
import { default as Y } from "./object-keys-sort/index.js";
|
|
30
|
-
import { default as oo } from "./pinyin/src/simplified.js";
|
|
31
|
-
import { default as ro } from "./screenfull/index.js";
|
|
32
|
-
import { TinyColor as ao } from "./tinycolor/src/index.js";
|
|
33
|
-
import * as x from "./cookie/src/index.js";
|
|
1
|
+
import { VERSION as e } from "./version/index.js";
|
|
34
2
|
export {
|
|
35
|
-
|
|
36
|
-
u as caseName,
|
|
37
|
-
C as className,
|
|
38
|
-
b as clipboardCopy,
|
|
39
|
-
o as constant,
|
|
40
|
-
k as contentDisposition,
|
|
41
|
-
x as cookie,
|
|
42
|
-
e as date,
|
|
43
|
-
S as decimal,
|
|
44
|
-
j as diff,
|
|
45
|
-
L as emitter,
|
|
46
|
-
P as fileToURL,
|
|
47
|
-
R as filesize,
|
|
48
|
-
f as filesizeConstants,
|
|
49
|
-
y as getContentDispositionFromHeader,
|
|
50
|
-
T as getContentDispositionParametersFilenameFromHeader,
|
|
51
|
-
g as getContentDispositionParametersFromHeader,
|
|
52
|
-
$ as invariant,
|
|
53
|
-
r as is,
|
|
54
|
-
w as jsCookie,
|
|
55
|
-
t as math,
|
|
56
|
-
G as md5,
|
|
57
|
-
J as normalizeWheel,
|
|
58
|
-
O as numberToChinese,
|
|
59
|
-
V as nzh,
|
|
60
|
-
Y as objectKeysSort,
|
|
61
|
-
U as partial,
|
|
62
|
-
oo as pinyin,
|
|
63
|
-
E as saveAs,
|
|
64
|
-
ro as screenfull,
|
|
65
|
-
a as snapdom,
|
|
66
|
-
D as splitCookiesString,
|
|
67
|
-
ao as tinycolor,
|
|
68
|
-
s as tree,
|
|
69
|
-
i as turboStream,
|
|
70
|
-
m as uiColor,
|
|
71
|
-
p as urlToolkit
|
|
3
|
+
e as version
|
|
72
4
|
};
|
package/nzh/src/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getNumbResult as R, clearZero as Y, unshiftZero as L, centerArray as j,
|
|
1
|
+
import { getNumbResult as R, extend as E, clearZero as Y, unshiftZero as L, centerArray as j, getDigit as C } from "./utils.js";
|
|
2
2
|
function z(m, h) {
|
|
3
3
|
let _ = R(m);
|
|
4
4
|
if (!_)
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@unicom-cloud/utils","version":"0.1.
|
|
1
|
+
{"name":"@unicom-cloud/utils","version":"0.1.22","dependencies":{},"peerDependencies":{"lodash":"^4.17.21"},"main":"./index.js","type":"module","types":"types/index.d.ts","publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"}}
|
package/tree/search/index.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import "../../is/index.js";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import S from "lodash/isArray";
|
|
3
|
+
import B from "lodash/isObjectLike";
|
|
4
|
+
import m from "lodash/isString";
|
|
5
|
+
import C from "lodash/isNumber";
|
|
6
|
+
import K from "lodash/isFunction";
|
|
7
|
+
import L from "lodash/isRegExp";
|
|
8
|
+
function j(o, f, h, w) {
|
|
9
|
+
return f && o ? { shouldExit: !0, newMatch: !0 } : h && !o ? { shouldExit: !0, newMatch: !1 } : { shouldExit: !1, newMatch: w || o };
|
|
8
10
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
function k(o, f) {
|
|
12
|
+
const h = { ...o };
|
|
13
|
+
return delete h[f], h;
|
|
14
|
+
}
|
|
15
|
+
function Q(o, f, h = {}) {
|
|
16
|
+
if (!S(o)) throw new TypeError("参数 treeData 必须是一个数组");
|
|
17
|
+
if (!B(f)) throw new TypeError("参数 searchCondition 必须是一个对象");
|
|
18
|
+
const w = {
|
|
13
19
|
strategy: "BFS",
|
|
14
20
|
childrenKey: "children",
|
|
15
21
|
strict: !1,
|
|
@@ -18,73 +24,96 @@ function q(r, l, a = {}) {
|
|
|
18
24
|
caseSensitive: !1,
|
|
19
25
|
allowEmptyString: !1,
|
|
20
26
|
matchMode: "AND",
|
|
21
|
-
|
|
27
|
+
returnTree: !1,
|
|
28
|
+
returnTreeMaxDepth: 0,
|
|
29
|
+
// 只在 returnTree 为 true 时才生效
|
|
30
|
+
...h
|
|
22
31
|
// 用户配置覆盖默认值
|
|
23
32
|
}, {
|
|
24
|
-
strategy:
|
|
25
|
-
childrenKey:
|
|
26
|
-
strict:
|
|
27
|
-
fuzzyMatch:
|
|
28
|
-
returnAllMatches:
|
|
29
|
-
caseSensitive:
|
|
30
|
-
allowEmptyString:
|
|
31
|
-
matchMode:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (!
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
strategy: E,
|
|
34
|
+
childrenKey: a,
|
|
35
|
+
strict: R,
|
|
36
|
+
fuzzyMatch: b,
|
|
37
|
+
returnAllMatches: M,
|
|
38
|
+
caseSensitive: v,
|
|
39
|
+
allowEmptyString: z,
|
|
40
|
+
matchMode: T,
|
|
41
|
+
returnTree: g,
|
|
42
|
+
returnTreeMaxDepth: p
|
|
43
|
+
} = w, D = T === "OR", x = T === "AND", y = E === "BFS";
|
|
44
|
+
if (!(y || E === "DFS")) throw new Error('配置 strategy 必须是 "BFS" 或 "DFS"');
|
|
45
|
+
if (!(D || x)) throw new Error('配置 matchMode 必须是 "AND" 或 "OR"');
|
|
46
|
+
if (!m(a)) throw new TypeError("配置 childrenKey 必须是字符串");
|
|
47
|
+
if (g) {
|
|
48
|
+
if (!M) throw new Error(
|
|
49
|
+
"当 returnTree 为 true 时,returnAllMatches 也必须为 true"
|
|
50
|
+
);
|
|
51
|
+
if (!(C(p) && p > -1)) throw new TypeError("配置 returnTreeMaxDepth 必须是一个非负整数");
|
|
52
|
+
}
|
|
53
|
+
const d = [...o], A = [], F = Object.entries(f);
|
|
54
|
+
if (F.length) {
|
|
55
|
+
const N = (r) => {
|
|
56
|
+
let s = !1;
|
|
57
|
+
for (const [n, e] of F) {
|
|
58
|
+
const t = r[n];
|
|
59
|
+
if (e === "" && !z)
|
|
43
60
|
continue;
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
} catch {
|
|
56
|
-
o = !1;
|
|
57
|
-
}
|
|
58
|
-
const u = v(o, M, g, t);
|
|
61
|
+
let i = !1;
|
|
62
|
+
if (K(e))
|
|
63
|
+
i = !!e(t, r);
|
|
64
|
+
else if (L(e) && m(t))
|
|
65
|
+
i = t ? e.test(t) : !1;
|
|
66
|
+
else if (b && m(e) && m(t)) {
|
|
67
|
+
let l = e, c = t;
|
|
68
|
+
v || (l = e.toLowerCase(), c = t.toLowerCase()), i = c.includes(l);
|
|
69
|
+
} else
|
|
70
|
+
i = R ? t === e : t == e;
|
|
71
|
+
const u = j(i, D, x, s);
|
|
59
72
|
if (u.shouldExit)
|
|
60
73
|
return u.newMatch;
|
|
61
|
-
|
|
74
|
+
s = u.newMatch;
|
|
62
75
|
}
|
|
63
|
-
return
|
|
76
|
+
return s;
|
|
64
77
|
};
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
78
|
+
if (g) {
|
|
79
|
+
const r = (n, e = 1) => {
|
|
80
|
+
const t = p > 0 && e > p, i = !t && N(n), u = t ? void 0 : n[a], l = [];
|
|
81
|
+
if (S(u))
|
|
82
|
+
for (const c of u) {
|
|
83
|
+
const O = r(c, e + 1);
|
|
84
|
+
O && l.push(O);
|
|
85
|
+
}
|
|
86
|
+
if (i || l.length > 0) {
|
|
87
|
+
const c = k(n, a);
|
|
88
|
+
return l.length > 0 && (c[a] = l), c;
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}, s = [];
|
|
92
|
+
for (const n of o) {
|
|
93
|
+
const e = r(n, 1);
|
|
94
|
+
e && s.push(e);
|
|
95
|
+
}
|
|
96
|
+
return s;
|
|
97
|
+
} else
|
|
98
|
+
for (; d.length > 0; ) {
|
|
99
|
+
const r = y ? d.shift() : d.pop();
|
|
100
|
+
if (!r) continue;
|
|
101
|
+
if (N(r))
|
|
102
|
+
if (M)
|
|
103
|
+
A.push(r);
|
|
104
|
+
else
|
|
105
|
+
return r;
|
|
106
|
+
const s = r[a];
|
|
107
|
+
if (S(s))
|
|
70
108
|
if (y)
|
|
71
|
-
|
|
109
|
+
d.push(...s);
|
|
72
110
|
else
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
continue;
|
|
111
|
+
for (let n = s.length - 1; n >= 0; n--)
|
|
112
|
+
d.push(s[n]);
|
|
76
113
|
}
|
|
77
|
-
const t = s[S];
|
|
78
|
-
if (A(t))
|
|
79
|
-
if (h)
|
|
80
|
-
c.push(...t);
|
|
81
|
-
else
|
|
82
|
-
for (let n = t.length - 1; n >= 0; n--)
|
|
83
|
-
c.push(t[n]);
|
|
84
|
-
}
|
|
85
114
|
}
|
|
86
|
-
return
|
|
115
|
+
return M ? A : null;
|
|
87
116
|
}
|
|
88
117
|
export {
|
|
89
|
-
|
|
118
|
+
Q as default
|
|
90
119
|
};
|
package/types/index.d.ts
CHANGED
|
@@ -1,30 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * as date from "./date";
|
|
3
|
-
export * as is from "./is";
|
|
4
|
-
export * as math from "./math";
|
|
5
|
-
export * as snapdom from "./snapdom";
|
|
6
|
-
export * as tree from "./tree";
|
|
7
|
-
export * as turboStream from "./turbo-stream";
|
|
8
|
-
export * as uiColor from "./ui-color";
|
|
9
|
-
export * as urlToolkit from "./url-toolkit";
|
|
10
|
-
export { default as caseName } from "./case-name";
|
|
11
|
-
export { default as className } from "./class-name";
|
|
12
|
-
export { default as clipboardCopy } from "./clipboard-copy";
|
|
13
|
-
export { default as decimal } from "./decimal";
|
|
14
|
-
export { default as diff } from "./diff";
|
|
15
|
-
export { default as emitter } from "./emitter";
|
|
16
|
-
export { default as invariant } from "./invariant";
|
|
17
|
-
export { default as jsCookie } from "./js-cookie";
|
|
18
|
-
export { default as Lunar } from "./lunar";
|
|
19
|
-
export { default as md5 } from "./md5";
|
|
20
|
-
export { default as normalizeWheel } from "./normalize-wheel";
|
|
21
|
-
export { default as numberToChinese } from "./number-to-chinese";
|
|
22
|
-
export { default as nzh } from "./nzh";
|
|
23
|
-
export { default as objectKeysSort } from "./object-keys-sort";
|
|
24
|
-
export { default as pinyin } from "./pinyin";
|
|
25
|
-
export { default as screenfull } from "./screenfull";
|
|
26
|
-
export { default as tinycolor } from "./tinycolor";
|
|
27
|
-
export { default as contentDisposition, getContentDispositionFromHeader, getContentDispositionParametersFilenameFromHeader, getContentDispositionParametersFromHeader } from "./content-disposition";
|
|
28
|
-
export { default as cookie, splitCookiesString } from "./cookie";
|
|
29
|
-
export { fileToURL, saveAs } from "./file";
|
|
30
|
-
export { default as filesize, filesizeConstants, partial } from "./filesize";
|
|
1
|
+
export { default as version } from "./version";
|
package/types/is/index.d.ts
CHANGED
|
@@ -3,25 +3,17 @@ import isArray from 'lodash/isArray';
|
|
|
3
3
|
import isArrayBuffer from 'lodash/isArrayBuffer';
|
|
4
4
|
import isArrayLike from 'lodash/isArrayLike';
|
|
5
5
|
import isArrayLikeObject from 'lodash/isArrayLikeObject';
|
|
6
|
-
export function isBlob(o: any): boolean;
|
|
7
6
|
import isBoolean from 'lodash/isBoolean';
|
|
8
7
|
import isBuffer from 'lodash/isBuffer';
|
|
9
|
-
export function isColor(color: any): boolean;
|
|
10
|
-
export function isColor2(color: any): boolean;
|
|
11
8
|
import isDate from 'lodash/isDate';
|
|
12
9
|
import isElement from 'lodash/isElement';
|
|
13
10
|
import isEmpty from 'lodash/isEmpty';
|
|
14
|
-
export function isEmptyArray(o: any): boolean;
|
|
15
|
-
export function isEmptyObject(o: any): boolean;
|
|
16
|
-
export function isEmptyValue(o: any): boolean;
|
|
17
11
|
import isEqual from 'lodash/isEqual';
|
|
18
12
|
import isEqualWith from 'lodash/isEqualWith';
|
|
19
13
|
import isError from 'lodash/isError';
|
|
20
|
-
export function isFile(o: any): boolean;
|
|
21
14
|
import isFinite from 'lodash/isFinite';
|
|
22
15
|
import isFunction from 'lodash/isFunction';
|
|
23
16
|
import isInteger from 'lodash/isInteger';
|
|
24
|
-
export function isJSON(text: any): boolean;
|
|
25
17
|
import isLength from 'lodash/isLength';
|
|
26
18
|
import isMap from 'lodash/isMap';
|
|
27
19
|
import isMatch from 'lodash/isMatch';
|
|
@@ -34,12 +26,6 @@ import isNumber from 'lodash/isNumber';
|
|
|
34
26
|
import isObject from 'lodash/isObject';
|
|
35
27
|
import isObjectLike from 'lodash/isObjectLike';
|
|
36
28
|
import isPlainObject from 'lodash/isPlainObject';
|
|
37
|
-
export function isPromise(p: any): p is Promise<any>;
|
|
38
|
-
export const isReadableByteStreamControllerSupported: boolean;
|
|
39
|
-
export function isReadableStream(params: any): boolean;
|
|
40
|
-
export const isReadableStreamDefaultControllerSupported: boolean;
|
|
41
|
-
export const isReadableStreamSupported: boolean;
|
|
42
|
-
export const isReadableStreamSymbolAsyncIteratorSupported: any;
|
|
43
29
|
import isRegExp from 'lodash/isRegExp';
|
|
44
30
|
import isSafeInteger from 'lodash/isSafeInteger';
|
|
45
31
|
import isSet from 'lodash/isSet';
|
|
@@ -47,7 +33,21 @@ import isString from 'lodash/isString';
|
|
|
47
33
|
import isSymbol from 'lodash/isSymbol';
|
|
48
34
|
import isTypedArray from 'lodash/isTypedArray';
|
|
49
35
|
import isUndefined from 'lodash/isUndefined';
|
|
50
|
-
export function isValidColor(value: any): boolean;
|
|
51
36
|
import isWeakMap from 'lodash/isWeakMap';
|
|
52
37
|
import isWeakSet from 'lodash/isWeakSet';
|
|
53
|
-
|
|
38
|
+
declare function isPromise(p: any): p is Promise<any>;
|
|
39
|
+
declare function isEmptyArray(o: any): boolean;
|
|
40
|
+
declare function isEmptyObject(o: any): boolean;
|
|
41
|
+
declare function isEmptyValue(o: any): boolean;
|
|
42
|
+
declare function isFile(o: any): boolean;
|
|
43
|
+
declare function isBlob(o: any): boolean;
|
|
44
|
+
declare function isReadableStream(params: any): boolean;
|
|
45
|
+
declare const isReadableStreamSupported: boolean;
|
|
46
|
+
declare const isReadableStreamDefaultControllerSupported: boolean;
|
|
47
|
+
declare const isReadableByteStreamControllerSupported: boolean;
|
|
48
|
+
declare const isReadableStreamSymbolAsyncIteratorSupported: any;
|
|
49
|
+
declare function isJSON(text: any): boolean;
|
|
50
|
+
declare function isColor(color: any): boolean;
|
|
51
|
+
declare function isColor2(color: any): boolean;
|
|
52
|
+
declare function isValidColor(value: any): boolean;
|
|
53
|
+
export { isArguments, isArray, isArrayBuffer, isArrayLike, isArrayLikeObject, isBlob, isBoolean, isBuffer, isColor, isColor2, isDate, isElement, isEmpty, isEmptyArray, isEmptyObject, isEmptyValue, isEqual, isEqualWith, isError, isFile, isFinite, isFunction, isInteger, isJSON, isLength, isMap, isMatch, isMatchWith, isNaN, isNative, isNil, isNull, isNumber, isObject, isObjectLike, isPlainObject, isPromise, isReadableByteStreamControllerSupported, isReadableStream, isReadableStreamDefaultControllerSupported, isReadableStreamSupported, isReadableStreamSymbolAsyncIteratorSupported, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isUndefined, isValidColor, isWeakMap, isWeakSet, };
|
|
@@ -9,7 +9,7 @@ type Primitive = string | number | boolean | symbol | null | undefined;
|
|
|
9
9
|
* 3. 正则表达式
|
|
10
10
|
* @template T 节点值的泛型类型
|
|
11
11
|
*/
|
|
12
|
-
type ConditionValue<T = unknown> = Primitive | ((value: T) => boolean) | RegExp;
|
|
12
|
+
type ConditionValue<T = unknown> = Primitive | ((value: T, node?: TreeNode) => boolean) | RegExp;
|
|
13
13
|
/**
|
|
14
14
|
* 树搜索配置选项接口
|
|
15
15
|
*/
|
|
@@ -54,6 +54,16 @@ interface SearchOptions {
|
|
|
54
54
|
* @default false
|
|
55
55
|
*/
|
|
56
56
|
allowEmptyString?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* 是否以树结构返回结果(保留父子关系)
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
returnTree?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* 搜索深度限制(从1开始计数),0表示无限制
|
|
64
|
+
* @default 0
|
|
65
|
+
*/
|
|
66
|
+
returnTreeMaxDepth?: number;
|
|
57
67
|
}
|
|
58
68
|
/**
|
|
59
69
|
* 树节点接口定义
|
|
@@ -80,11 +80,11 @@ export declare class TurboBlob extends Blob {
|
|
|
80
80
|
text(): Promise<string>;
|
|
81
81
|
}
|
|
82
82
|
declare const FileBaseClass: {
|
|
83
|
-
new (blobParts?: BlobPart[], options?: BlobPropertyBag): Blob;
|
|
84
|
-
prototype: Blob;
|
|
85
|
-
} | {
|
|
86
83
|
new (fileBits: BlobPart[], fileName: string, options?: FilePropertyBag): File;
|
|
87
84
|
prototype: File;
|
|
85
|
+
} | {
|
|
86
|
+
new (blobParts?: BlobPart[], options?: BlobPropertyBag): Blob;
|
|
87
|
+
prototype: Blob;
|
|
88
88
|
};
|
|
89
89
|
export declare class TurboFile extends FileBaseClass {
|
|
90
90
|
#private;
|
package/version/index.js
ADDED
package/version.js
ADDED
package/diff/index.js
DELETED
package/diff/src/diff.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
declare function diff(
|
|
2
|
-
text1: string,
|
|
3
|
-
text2: string,
|
|
4
|
-
cursorPos?: number | diff.CursorInfo,
|
|
5
|
-
cleanup?: boolean,
|
|
6
|
-
): diff.Diff[];
|
|
7
|
-
|
|
8
|
-
declare namespace diff {
|
|
9
|
-
type Diff = [-1 | 0 | 1, string];
|
|
10
|
-
|
|
11
|
-
const DELETE: -1;
|
|
12
|
-
const INSERT: 1;
|
|
13
|
-
const EQUAL: 0;
|
|
14
|
-
|
|
15
|
-
interface CursorInfo {
|
|
16
|
-
oldRange: { index: number; length: number };
|
|
17
|
-
newRange: { index: number; length: number };
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export = diff;
|
package/diff/src/diff.js
DELETED
|
@@ -1,381 +0,0 @@
|
|
|
1
|
-
let L = -1, w = 1, A = 0;
|
|
2
|
-
function S(e, t, l, r, i) {
|
|
3
|
-
if (e === t)
|
|
4
|
-
return e ? [[A, e]] : [];
|
|
5
|
-
if (l != null) {
|
|
6
|
-
let a = T(e, t, l);
|
|
7
|
-
if (a)
|
|
8
|
-
return a;
|
|
9
|
-
}
|
|
10
|
-
let n = D(e, t), h = e.substring(0, n);
|
|
11
|
-
e = e.substring(n), t = t.substring(n), n = I(e, t);
|
|
12
|
-
let g = e.substring(e.length - n);
|
|
13
|
-
e = e.substring(0, e.length - n), t = t.substring(0, t.length - n);
|
|
14
|
-
let s = G(e, t);
|
|
15
|
-
return h && s.unshift([A, h]), g && s.push([A, g]), F(s, i), r && K(s), s;
|
|
16
|
-
}
|
|
17
|
-
function G(e, t) {
|
|
18
|
-
let l;
|
|
19
|
-
if (!e)
|
|
20
|
-
return [[w, t]];
|
|
21
|
-
if (!t)
|
|
22
|
-
return [[L, e]];
|
|
23
|
-
let r = e.length > t.length ? e : t, i = e.length > t.length ? t : e, n = r.indexOf(i);
|
|
24
|
-
if (n !== -1)
|
|
25
|
-
return l = [
|
|
26
|
-
[w, r.substring(0, n)],
|
|
27
|
-
[A, i],
|
|
28
|
-
[w, r.substring(n + i.length)]
|
|
29
|
-
], e.length > t.length && (l[0][0] = l[2][0] = L), l;
|
|
30
|
-
if (i.length === 1)
|
|
31
|
-
return [
|
|
32
|
-
[L, e],
|
|
33
|
-
[w, t]
|
|
34
|
-
];
|
|
35
|
-
let h = J(e, t);
|
|
36
|
-
if (h) {
|
|
37
|
-
let g = h[0], s = h[1], a = h[2], u = h[3], c = h[4], f = S(g, a), b = S(s, u);
|
|
38
|
-
return f.concat([[A, c]], b);
|
|
39
|
-
}
|
|
40
|
-
return H(e, t);
|
|
41
|
-
}
|
|
42
|
-
function H(e, t) {
|
|
43
|
-
let l = e.length, r = t.length, i = Math.ceil((l + r) / 2), n = i, h = 2 * i, g = new Array(h), s = new Array(h);
|
|
44
|
-
for (let _ = 0; _ < h; _++)
|
|
45
|
-
g[_] = -1, s[_] = -1;
|
|
46
|
-
g[n + 1] = 0, s[n + 1] = 0;
|
|
47
|
-
let a = l - r, u = a % 2 !== 0, c = 0, f = 0, b = 0, p = 0;
|
|
48
|
-
for (let _ = 0; _ < i; _++) {
|
|
49
|
-
for (let k = -_ + c; k <= _ - f; k += 2) {
|
|
50
|
-
let m = n + k, o;
|
|
51
|
-
k === -_ || k !== _ && g[m - 1] < g[m + 1] ? o = g[m + 1] : o = g[m - 1] + 1;
|
|
52
|
-
let M = o - k;
|
|
53
|
-
for (; o < l && M < r && e.charAt(o) === t.charAt(M); )
|
|
54
|
-
o++, M++;
|
|
55
|
-
if (g[m] = o, o > l)
|
|
56
|
-
f += 2;
|
|
57
|
-
else if (M > r)
|
|
58
|
-
c += 2;
|
|
59
|
-
else if (u) {
|
|
60
|
-
let E = n + a - k;
|
|
61
|
-
if (E >= 0 && E < h && s[E] !== -1) {
|
|
62
|
-
let y = l - s[E];
|
|
63
|
-
if (o >= y)
|
|
64
|
-
return C(e, t, o, M);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
for (let k = -_ + b; k <= _ - p; k += 2) {
|
|
69
|
-
let m = n + k, o;
|
|
70
|
-
k === -_ || k !== _ && s[m - 1] < s[m + 1] ? o = s[m + 1] : o = s[m - 1] + 1;
|
|
71
|
-
let M = o - k;
|
|
72
|
-
for (; o < l && M < r && e.charAt(l - o - 1) === t.charAt(r - M - 1); )
|
|
73
|
-
o++, M++;
|
|
74
|
-
if (s[m] = o, o > l)
|
|
75
|
-
p += 2;
|
|
76
|
-
else if (M > r)
|
|
77
|
-
b += 2;
|
|
78
|
-
else if (!u) {
|
|
79
|
-
let E = n + a - k;
|
|
80
|
-
if (E >= 0 && E < h && g[E] !== -1) {
|
|
81
|
-
let y = g[E], R = n + y - E;
|
|
82
|
-
if (o = l - o, y >= o)
|
|
83
|
-
return C(e, t, y, R);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return [
|
|
89
|
-
[L, e],
|
|
90
|
-
[w, t]
|
|
91
|
-
];
|
|
92
|
-
}
|
|
93
|
-
function C(e, t, l, r) {
|
|
94
|
-
let i = e.substring(0, l), n = t.substring(0, r), h = e.substring(l), g = t.substring(r), s = S(i, n), a = S(h, g);
|
|
95
|
-
return s.concat(a);
|
|
96
|
-
}
|
|
97
|
-
function D(e, t) {
|
|
98
|
-
if (!e || !t || e.charAt(0) !== t.charAt(0))
|
|
99
|
-
return 0;
|
|
100
|
-
let l = 0, r = Math.min(e.length, t.length), i = r, n = 0;
|
|
101
|
-
for (; l < i; )
|
|
102
|
-
e.substring(n, i) == t.substring(n, i) ? (l = i, n = l) : r = i, i = Math.floor((r - l) / 2 + l);
|
|
103
|
-
return j(e.charCodeAt(i - 1)) && i--, i;
|
|
104
|
-
}
|
|
105
|
-
function O(e, t) {
|
|
106
|
-
let l = e.length, r = t.length;
|
|
107
|
-
if (l == 0 || r == 0)
|
|
108
|
-
return 0;
|
|
109
|
-
l > r ? e = e.substring(l - r) : l < r && (t = t.substring(0, l));
|
|
110
|
-
let i = Math.min(l, r);
|
|
111
|
-
if (e == t)
|
|
112
|
-
return i;
|
|
113
|
-
let n = 0, h = 1;
|
|
114
|
-
for (; ; ) {
|
|
115
|
-
let g = e.substring(i - h), s = t.indexOf(g);
|
|
116
|
-
if (s == -1)
|
|
117
|
-
return n;
|
|
118
|
-
h += s, (s == 0 || e.substring(i - h) == t.substring(0, h)) && (n = h, h++);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
function I(e, t) {
|
|
122
|
-
if (!e || !t || e.slice(-1) !== t.slice(-1))
|
|
123
|
-
return 0;
|
|
124
|
-
let l = 0, r = Math.min(e.length, t.length), i = r, n = 0;
|
|
125
|
-
for (; l < i; )
|
|
126
|
-
e.substring(e.length - i, e.length - n) == t.substring(t.length - i, t.length - n) ? (l = i, n = l) : r = i, i = Math.floor((r - l) / 2 + l);
|
|
127
|
-
return z(e.charCodeAt(e.length - i)) && i--, i;
|
|
128
|
-
}
|
|
129
|
-
function J(e, t) {
|
|
130
|
-
let l = e.length > t.length ? e : t, r = e.length > t.length ? t : e;
|
|
131
|
-
if (l.length < 4 || r.length * 2 < l.length)
|
|
132
|
-
return null;
|
|
133
|
-
function i(b, p, _) {
|
|
134
|
-
let k = b.substring(_, _ + Math.floor(b.length / 4)), m = -1, o = "", M, E, y, R;
|
|
135
|
-
for (; (m = p.indexOf(k, m + 1)) !== -1; ) {
|
|
136
|
-
let v = D(
|
|
137
|
-
b.substring(_),
|
|
138
|
-
p.substring(m)
|
|
139
|
-
), q = I(
|
|
140
|
-
b.substring(0, _),
|
|
141
|
-
p.substring(0, m)
|
|
142
|
-
);
|
|
143
|
-
o.length < q + v && (o = p.substring(m - q, m) + p.substring(m, m + v), M = b.substring(0, _ - q), E = b.substring(_ + v), y = p.substring(0, m - q), R = p.substring(m + v));
|
|
144
|
-
}
|
|
145
|
-
return o.length * 2 >= b.length ? [
|
|
146
|
-
M,
|
|
147
|
-
E,
|
|
148
|
-
y,
|
|
149
|
-
R,
|
|
150
|
-
o
|
|
151
|
-
] : null;
|
|
152
|
-
}
|
|
153
|
-
let n = i(
|
|
154
|
-
l,
|
|
155
|
-
r,
|
|
156
|
-
Math.ceil(l.length / 4)
|
|
157
|
-
), h = i(
|
|
158
|
-
l,
|
|
159
|
-
r,
|
|
160
|
-
Math.ceil(l.length / 2)
|
|
161
|
-
), g;
|
|
162
|
-
if (!n && !h)
|
|
163
|
-
return null;
|
|
164
|
-
h ? n ? g = n[4].length > h[4].length ? n : h : g = h : g = n;
|
|
165
|
-
let s, a, u, c;
|
|
166
|
-
e.length > t.length ? (s = g[0], a = g[1], u = g[2], c = g[3]) : (u = g[0], c = g[1], s = g[2], a = g[3]);
|
|
167
|
-
let f = g[4];
|
|
168
|
-
return [s, a, u, c, f];
|
|
169
|
-
}
|
|
170
|
-
function K(e) {
|
|
171
|
-
let t = !1, l = [], r = 0, i = null, n = 0, h = 0, g = 0, s = 0, a = 0;
|
|
172
|
-
for (; n < e.length; )
|
|
173
|
-
e[n][0] == A ? (l[r++] = n, h = s, g = a, s = 0, a = 0, i = e[n][1]) : (e[n][0] == w ? s += e[n][1].length : a += e[n][1].length, i && i.length <= Math.max(h, g) && i.length <= Math.max(s, a) && (e.splice(l[r - 1], 0, [
|
|
174
|
-
L,
|
|
175
|
-
i
|
|
176
|
-
]), e[l[r - 1] + 1][0] = w, r--, r--, n = r > 0 ? l[r - 1] : -1, h = 0, g = 0, s = 0, a = 0, i = null, t = !0)), n++;
|
|
177
|
-
for (t && F(e), X(e), n = 1; n < e.length; ) {
|
|
178
|
-
if (e[n - 1][0] == L && e[n][0] == w) {
|
|
179
|
-
let u = e[n - 1][1], c = e[n][1], f = O(u, c), b = O(c, u);
|
|
180
|
-
f >= b ? (f >= u.length / 2 || f >= c.length / 2) && (e.splice(n, 0, [
|
|
181
|
-
A,
|
|
182
|
-
c.substring(0, f)
|
|
183
|
-
]), e[n - 1][1] = u.substring(
|
|
184
|
-
0,
|
|
185
|
-
u.length - f
|
|
186
|
-
), e[n + 1][1] = c.substring(f), n++) : (b >= u.length / 2 || b >= c.length / 2) && (e.splice(n, 0, [
|
|
187
|
-
A,
|
|
188
|
-
u.substring(0, b)
|
|
189
|
-
]), e[n - 1][0] = w, e[n - 1][1] = c.substring(
|
|
190
|
-
0,
|
|
191
|
-
c.length - b
|
|
192
|
-
), e[n + 1][0] = L, e[n + 1][1] = u.substring(b), n++), n++;
|
|
193
|
-
}
|
|
194
|
-
n++;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
let P = /[^a-zA-Z0-9]/, Q = /\s/, U = /[\r\n]/, V = /\n\r?\n$/, W = /^\r?\n\r?\n/;
|
|
198
|
-
function X(e) {
|
|
199
|
-
function t(r, i) {
|
|
200
|
-
if (!r || !i)
|
|
201
|
-
return 6;
|
|
202
|
-
let n = r.charAt(r.length - 1), h = i.charAt(0), g = n.match(P), s = h.match(P), a = g && n.match(Q), u = s && h.match(Q), c = a && n.match(U), f = u && h.match(U), b = c && r.match(V), p = f && i.match(W);
|
|
203
|
-
return b || p ? 5 : c || f ? 4 : g && !a && u ? 3 : a || u ? 2 : g || s ? 1 : 0;
|
|
204
|
-
}
|
|
205
|
-
let l = 1;
|
|
206
|
-
for (; l < e.length - 1; ) {
|
|
207
|
-
if (e[l - 1][0] == A && e[l + 1][0] == A) {
|
|
208
|
-
let r = e[l - 1][1], i = e[l][1], n = e[l + 1][1], h = I(r, i);
|
|
209
|
-
if (h) {
|
|
210
|
-
let c = i.substring(i.length - h);
|
|
211
|
-
r = r.substring(0, r.length - h), i = c + i.substring(0, i.length - h), n = c + n;
|
|
212
|
-
}
|
|
213
|
-
let g = r, s = i, a = n, u = t(r, i) + t(i, n);
|
|
214
|
-
for (; i.charAt(0) === n.charAt(0); ) {
|
|
215
|
-
r += i.charAt(0), i = i.substring(1) + n.charAt(0), n = n.substring(1);
|
|
216
|
-
let c = t(r, i) + t(i, n);
|
|
217
|
-
c >= u && (u = c, g = r, s = i, a = n);
|
|
218
|
-
}
|
|
219
|
-
e[l - 1][1] != g && (g ? e[l - 1][1] = g : (e.splice(l - 1, 1), l--), e[l][1] = s, a ? e[l + 1][1] = a : (e.splice(l + 1, 1), l--));
|
|
220
|
-
}
|
|
221
|
-
l++;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
function F(e, t) {
|
|
225
|
-
e.push([A, ""]);
|
|
226
|
-
let l = 0, r = 0, i = 0, n = "", h = "", g;
|
|
227
|
-
for (; l < e.length; ) {
|
|
228
|
-
if (l < e.length - 1 && !e[l][1]) {
|
|
229
|
-
e.splice(l, 1);
|
|
230
|
-
continue;
|
|
231
|
-
}
|
|
232
|
-
switch (e[l][0]) {
|
|
233
|
-
case w: {
|
|
234
|
-
i++, h += e[l][1], l++;
|
|
235
|
-
break;
|
|
236
|
-
}
|
|
237
|
-
case L:
|
|
238
|
-
r++, n += e[l][1], l++;
|
|
239
|
-
break;
|
|
240
|
-
case A: {
|
|
241
|
-
let a = l - i - r - 1;
|
|
242
|
-
if (t) {
|
|
243
|
-
if (a >= 0 && $(e[a][1])) {
|
|
244
|
-
let u = e[a][1].slice(-1);
|
|
245
|
-
if (e[a][1] = e[a][1].slice(
|
|
246
|
-
0,
|
|
247
|
-
-1
|
|
248
|
-
), n = u + n, h = u + h, !e[a][1]) {
|
|
249
|
-
e.splice(a, 1), l--;
|
|
250
|
-
let c = a - 1;
|
|
251
|
-
e[c] && e[c][0] === w && (i++, h = e[c][1] + h, c--), e[c] && e[c][0] === L && (r++, n = e[c][1] + n, c--), a = c;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
if (Z(e[l][1])) {
|
|
255
|
-
let u = e[l][1].charAt(0);
|
|
256
|
-
e[l][1] = e[l][1].slice(1), n += u, h += u;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
if (l < e.length - 1 && !e[l][1]) {
|
|
260
|
-
e.splice(l, 1);
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
if (n.length > 0 || h.length > 0) {
|
|
264
|
-
n.length > 0 && h.length > 0 && (g = D(h, n), g !== 0 && (a >= 0 ? e[a][1] += h.substring(
|
|
265
|
-
0,
|
|
266
|
-
g
|
|
267
|
-
) : (e.splice(0, 0, [
|
|
268
|
-
A,
|
|
269
|
-
h.substring(0, g)
|
|
270
|
-
]), l++), h = h.substring(g), n = n.substring(g)), g = I(h, n), g !== 0 && (e[l][1] = h.substring(h.length - g) + e[l][1], h = h.substring(
|
|
271
|
-
0,
|
|
272
|
-
h.length - g
|
|
273
|
-
), n = n.substring(
|
|
274
|
-
0,
|
|
275
|
-
n.length - g
|
|
276
|
-
)));
|
|
277
|
-
let u = i + r;
|
|
278
|
-
n.length === 0 && h.length === 0 ? (e.splice(l - u, u), l = l - u) : n.length === 0 ? (e.splice(l - u, u, [w, h]), l = l - u + 1) : h.length === 0 ? (e.splice(l - u, u, [L, n]), l = l - u + 1) : (e.splice(
|
|
279
|
-
l - u,
|
|
280
|
-
u,
|
|
281
|
-
[L, n],
|
|
282
|
-
[w, h]
|
|
283
|
-
), l = l - u + 2);
|
|
284
|
-
}
|
|
285
|
-
l !== 0 && e[l - 1][0] === A ? (e[l - 1][1] += e[l][1], e.splice(l, 1)) : l++, i = 0, r = 0, n = "", h = "";
|
|
286
|
-
break;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
e[e.length - 1][1] === "" && e.pop();
|
|
291
|
-
let s = !1;
|
|
292
|
-
for (l = 1; l < e.length - 1; )
|
|
293
|
-
e[l - 1][0] === A && e[l + 1][0] === A && (e[l][1].substring(
|
|
294
|
-
e[l][1].length - e[l - 1][1].length
|
|
295
|
-
) === e[l - 1][1] ? (e[l][1] = e[l - 1][1] + e[l][1].substring(
|
|
296
|
-
0,
|
|
297
|
-
e[l][1].length - e[l - 1][1].length
|
|
298
|
-
), e[l + 1][1] = e[l - 1][1] + e[l + 1][1], e.splice(l - 1, 1), s = !0) : e[l][1].substring(0, e[l + 1][1].length) == e[l + 1][1] && (e[l - 1][1] += e[l + 1][1], e[l][1] = e[l][1].substring(e[l + 1][1].length) + e[l + 1][1], e.splice(l + 1, 1), s = !0)), l++;
|
|
299
|
-
s && F(e, t);
|
|
300
|
-
}
|
|
301
|
-
function j(e) {
|
|
302
|
-
return e >= 55296 && e <= 56319;
|
|
303
|
-
}
|
|
304
|
-
function z(e) {
|
|
305
|
-
return e >= 56320 && e <= 57343;
|
|
306
|
-
}
|
|
307
|
-
function Z(e) {
|
|
308
|
-
return z(e.charCodeAt(0));
|
|
309
|
-
}
|
|
310
|
-
function $(e) {
|
|
311
|
-
return j(e.charCodeAt(e.length - 1));
|
|
312
|
-
}
|
|
313
|
-
function Y(e) {
|
|
314
|
-
let t = [];
|
|
315
|
-
for (let l = 0; l < e.length; l++)
|
|
316
|
-
e[l][1].length > 0 && t.push(e[l]);
|
|
317
|
-
return t;
|
|
318
|
-
}
|
|
319
|
-
function N(e, t, l, r) {
|
|
320
|
-
return $(e) || Z(r) ? null : Y([
|
|
321
|
-
[A, e],
|
|
322
|
-
[L, t],
|
|
323
|
-
[w, l],
|
|
324
|
-
[A, r]
|
|
325
|
-
]);
|
|
326
|
-
}
|
|
327
|
-
function T(e, t, l) {
|
|
328
|
-
let r = typeof l == "number" ? { index: l, length: 0 } : l.oldRange, i = typeof l == "number" ? null : l.newRange, n = e.length, h = t.length;
|
|
329
|
-
if (r.length === 0 && (i === null || i.length === 0)) {
|
|
330
|
-
let g = r.index, s = e.slice(0, g), a = e.slice(g), u = i ? i.index : null;
|
|
331
|
-
e: {
|
|
332
|
-
let c = g + h - n;
|
|
333
|
-
if (u !== null && u !== c || c < 0 || c > h)
|
|
334
|
-
break e;
|
|
335
|
-
let f = t.slice(0, c);
|
|
336
|
-
if (t.slice(c) !== a)
|
|
337
|
-
break e;
|
|
338
|
-
let p = Math.min(g, c), _ = s.slice(0, p), k = f.slice(0, p);
|
|
339
|
-
if (_ !== k)
|
|
340
|
-
break e;
|
|
341
|
-
let m = s.slice(p), o = f.slice(p);
|
|
342
|
-
return N(_, m, o, a);
|
|
343
|
-
}
|
|
344
|
-
e: {
|
|
345
|
-
if (u !== null && u !== g)
|
|
346
|
-
break e;
|
|
347
|
-
let c = g, f = t.slice(0, c), b = t.slice(c);
|
|
348
|
-
if (f !== s)
|
|
349
|
-
break e;
|
|
350
|
-
let p = Math.min(n - c, h - c), _ = a.slice(a.length - p), k = b.slice(b.length - p);
|
|
351
|
-
if (_ !== k)
|
|
352
|
-
break e;
|
|
353
|
-
let m = a.slice(0, a.length - p), o = b.slice(0, b.length - p);
|
|
354
|
-
return N(s, m, o, _);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
if (r.length > 0 && i && i.length === 0)
|
|
358
|
-
e: {
|
|
359
|
-
let g = e.slice(0, r.index), s = e.slice(r.index + r.length), a = g.length, u = s.length;
|
|
360
|
-
if (h < a + u)
|
|
361
|
-
break e;
|
|
362
|
-
let c = t.slice(0, a), f = t.slice(h - u);
|
|
363
|
-
if (g !== c || s !== f)
|
|
364
|
-
break e;
|
|
365
|
-
let b = e.slice(a, n - u), p = t.slice(a, h - u);
|
|
366
|
-
return N(g, b, p, s);
|
|
367
|
-
}
|
|
368
|
-
return null;
|
|
369
|
-
}
|
|
370
|
-
function B(e, t, l, r) {
|
|
371
|
-
return S(e, t, l, r, !0);
|
|
372
|
-
}
|
|
373
|
-
B.INSERT = w;
|
|
374
|
-
B.DELETE = L;
|
|
375
|
-
B.EQUAL = A;
|
|
376
|
-
export {
|
|
377
|
-
L as DELETE,
|
|
378
|
-
A as EQUAL,
|
|
379
|
-
w as INSERT,
|
|
380
|
-
B as default
|
|
381
|
-
};
|
package/diff.js
DELETED
package/types/diff/index.d.ts
DELETED
package/types/diff/src/diff.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export default diff;
|
|
2
|
-
/**
|
|
3
|
-
* This library modifies the diff-patch-match library by Neil Fraser
|
|
4
|
-
* by removing the patch and match functionality and certain advanced
|
|
5
|
-
* options in the diff function. The original license is as follows:
|
|
6
|
-
*
|
|
7
|
-
* ===
|
|
8
|
-
*
|
|
9
|
-
* Diff Match and Patch
|
|
10
|
-
*
|
|
11
|
-
* Copyright 2006 Google Inc.
|
|
12
|
-
* http://code.google.com/p/google-diff-match-patch/
|
|
13
|
-
*
|
|
14
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15
|
-
* you may not use this file except in compliance with the License.
|
|
16
|
-
* You may obtain a copy of the License at
|
|
17
|
-
*
|
|
18
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
-
*
|
|
20
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
21
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
22
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
23
|
-
* See the License for the specific language governing permissions and
|
|
24
|
-
* limitations under the License.
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
27
|
-
* The data structure representing a diff is an array of tuples:
|
|
28
|
-
* [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
|
|
29
|
-
* which means: delete 'Hello', add 'Goodbye' and keep ' world.'
|
|
30
|
-
*/
|
|
31
|
-
declare let DIFF_DELETE: number;
|
|
32
|
-
declare let DIFF_EQUAL: number;
|
|
33
|
-
declare let DIFF_INSERT: number;
|
|
34
|
-
declare function diff(text1: any, text2: any, cursor_pos: any, cleanup: any): any[];
|
|
35
|
-
declare namespace diff {
|
|
36
|
-
export { DIFF_INSERT as INSERT };
|
|
37
|
-
export { DIFF_DELETE as DELETE };
|
|
38
|
-
export { DIFF_EQUAL as EQUAL };
|
|
39
|
-
}
|
|
40
|
-
export { DIFF_DELETE as DELETE, DIFF_EQUAL as EQUAL, DIFF_INSERT as INSERT };
|