@amaui/diff
Version:
Diff algorithm
49 lines (48 loc) • 1.5 kB
TypeScript
export declare type IDiffItemAction = 'add' | 'a' | 'remove' | 'r';
export declare type IDiffItem = [IDiffItemAction, number, string?];
export interface IDiff {
items: Array<IDiffItemAction | number | string>;
}
export interface IInit {
method?: (value: any) => string;
}
export interface IItemize {
method?: (value: string) => Array<string>;
}
export interface IEqual {
method: (value: string, value1: string) => boolean;
}
export interface IJoin {
method?: (value: Array<string>) => string;
}
export declare type IDiffMatrixItem = [number?, number?, number?];
export interface IOutput {
compressed?: boolean;
}
export interface IOptions {
init?: IInit;
itemize?: IItemize;
equal?: IEqual;
join?: IJoin;
output?: IOutput;
}
export declare type TDiffVariants = 'default' | 'word' | 'line' | 'sentence' | 'json';
export declare type IOPTIONS = {
[p in TDiffVariants]?: IOptions;
};
export declare const optionsDefault: IOptions;
declare class AmauiDiff {
options: IOptions;
static get amauidiff(): AmauiDiff;
static get word(): AmauiDiff;
static get line(): AmauiDiff;
static get sentence(): AmauiDiff;
static get json(): AmauiDiff;
static get OPTIONS(): IOPTIONS;
static updateGroups(diff: IDiff): any[];
constructor(options?: IOptions);
diff(value_: any, value1_: any, options_?: IOptions): IDiff;
update(value__: any, diff: IDiff, options_?: IOptions): string;
private action;
}
export default AmauiDiff;