export interface ILCSResult { buffer1index: number; buffer2index: number; chain: null | ILCSResult; } /** * Expects two arrays, finds longest common sequence * @param {T[]} buffer1 * @param {T[]} buffer2 * @returns {ILCSResult} * @constructor */ export function LCS(buffer1: T[], buffer2: T[]): ILCSResult; export interface ICommResult { buffer1: T[]; buffer2: T[]; } /** * We apply the LCS to build a 'comm'-style picture of the * differences between buffer1 and buffer2. * @param {T[]} buffer1 * @param {T[]} buffer2 * @returns {Array>} */ export function diffComm(buffer1: T[], buffer2: T[]): ICommResult[]; export interface IDiffIndicesResult { buffer1: [number, number]; buffer1Content: T[]; buffer2: [number, number]; buffer2Content: T[]; } /** * We apply the LCS to give a simple representation of the * offsets and lengths of mismatched chunks in the input * buffers. This is used by diff3MergeRegions. * @param {T[]} buffer1 * @param {T[]} buffer2 * @returns {IDiffIndicesResult[]} */ export function diffIndices( buffer1: T[], buffer2: T[] ): IDiffIndicesResult[]; export interface IChunk { offset: number; length: number; chunk: T[]; } export interface IPatchRes { buffer1: IChunk; buffer2: IChunk; } /** * We apply the LCS to build a JSON representation of a * diff(1)-style patch. * @param {T[]} buffer1 * @param {T[]} buffer2 * @returns {IPatchRes[]} */ export function diffPatch(buffer1: T[], buffer2: T[]): IPatchRes[]; export function patch(buffer: T[], patch: IPatchRes[]): T[]; export interface IStableRegion { stable: true; buffer: 'a' | 'o' | 'b'; bufferStart: number; bufferLength: number; bufferContent: T[]; } export interface IUnstableRegion { stable: false; aStart: number; aLength: number; aContent: T[]; bStart: number; bLength: number; bContent: T[]; oStart: number; oLength: number; oContent: T[]; } export type IRegion = IStableRegion | IUnstableRegion; /** * Given three buffers, A, O, and B, where both A and B are * independently derived from O, returns a fairly complicated * internal representation of merge decisions it's taken. The * interested reader may wish to consult * * Sanjeev Khanna, Keshav Kunal, and Benjamin C. Pierce. * 'A Formal Investigation of ' In Arvind and Prasad, * editors, Foundations of Software Technology and Theoretical * Computer Science (FSTTCS), December 2007. * * (http://www.cis.upenn.edu/~bcpierce/papers/diff3-short.pdf) * * @param {T[]} a * @param {T[]} o * @param {T[]} b * @returns {IRegion[]} */ export function diff3MergeRegions(a: T[], o: T[], b: T[]): IRegion[]; export interface MergeRegion { ok?: T[]; conflict?: { a: T[]; aIndex: number; b: T[]; bIndex: number; o: T[]; oIndex: number; }; } export interface MergeResult { conflict: boolean; result: string[]; } export interface IMergeOptions { excludeFalseConflicts?: boolean; stringSeparator?: string | RegExp; } /** * Applies the output of diff3MergeRegions to actually * construct the merged buffer; the returned result alternates * between 'ok' and 'conflict' blocks. * A "false conflict" is where `a` and `b` both change the same from `o` * * @param {string | T[]} a * @param {string | T[]} o * @param {string | T[]} b * @param {{excludeFalseConflicts: boolean; stringSeparator: RegExp}} options * @returns {MergeRegion[]} */ export function diff3Merge( a: string | T[], o: string | T[], b: string | T[], options?: IMergeOptions ): MergeRegion[]; export function merge( a: string | T[], o: string | T[], b: string | T[], options?: IMergeOptions ): MergeResult; export function mergeDiff3( a: string | T[], o: string | T[], b: string | T[], options?: IMergeOptions & { label?: { a?: string; o?: string; b?: string; } } ): MergeResult; export function mergeDigIn( a: string | T[], o: string | T[], b: string | T[], options?: IMergeOptions ): MergeResult;