/** diff结果 */ export declare enum DiffType { /** 删除 */ REMOVED = "removed", /** 共同 */ COMMON = "common", /** 添加 */ ADDED = "added" } export interface DiffResult { /** The type of the diff. */ type: DiffType; /** The value of the diff. */ value: T; /** The details of the diff. */ detail?: DiffResult[]; } /** ## `array_common_part` : 计算两个数组的公共前缀部分。 对于*公共前缀部分*定义如下: + 两个数组从开始到第一个不相同的元素之间的元素 @example Usage ```ts const arr1 = [3, 4, 1, 2] const arr2 = [3, 4, 5, 6] const result = array_common_part(arr1, arr2) console.log(result) assert(equal(result, [3, 4])) ``` @example Usage - empty ```ts const arr1 = [1, 2, 3, 4, 6] const arr2 = [3, 4, 5, 6, 6] const result = array_common_part(arr1, arr2) assert(equal(result, [])) ``` @returns 公共部分的数组 @category Algorithm */ export declare function array_common_part(arr1: T[], arr2: T[]): T[]; /** ## `diff_str` : 计算比较两字符串之差 采用逐字符比较的方式,记录从`a --> b`的变化 @example Usage ```ts const a = 'abcxyz' const b = 'abqxyzz' const expected = [ { type: DiffType.COMMON, value: 'ab' }, // 'ab' { type: DiffType.REMOVED, value: 'c' }, // c->' { type: DiffType.ADDED, value: 'q' }, // ''->q { type: DiffType.COMMON, value: 'xyz' }, // 'xyz' { type: DiffType.ADDED, value: 'z' }, // ''->z ] assert.equal(diff_str(a, b), expected) ``` @category Algorithm */ export declare function diff_str(a: string, b: string): DiffResult[]; //# sourceMappingURL=diff.d.ts.map