@ibyar/platform
Version:
Ibyar Platform, A utility package for Aurora
37 lines • 1.47 kB
TypeScript
export type TrackBy<T, R = T> = (index: number, item: T) => R;
export type DiffOptions<T, R = T> = {
trackBy?: TrackBy<T, R>;
};
export declare enum PatchOperation {
ADD = "add",
REMOVE = "remove",
REPLACE = "replace",
MOVE = "move",
KEEP = "keep"
}
export type PatchArray<T> = {
currentIndex: number;
nextIndex: number;
op: PatchOperation;
item: T;
};
export type PatchObject = {
key: string;
op: PatchOperation;
};
export declare const PatchRoot: {
op: PatchOperation;
root: boolean;
};
export type DiffPatch<T> = PatchArray<T> | PatchObject;
export declare class JSONPatch {
protected diffArray<T, R = T>(input: T[], output: T[], options?: DiffOptions<T, R>): PatchArray<T>[] | [typeof PatchRoot];
protected diffObject<T = any>(input: T, output: T): PatchObject[] | [typeof PatchRoot];
diff<T = any>(input: T, output: T): PatchObject[] | [typeof PatchRoot];
diff<T>(input: T[], output: T[]): PatchArray<T>[] | [typeof PatchRoot];
diff<T, R>(input: T[], output: T[], options?: DiffOptions<T, R>): PatchArray<T>[] | [typeof PatchRoot];
}
export declare function diff<T = any>(input: T, output: T): PatchObject[] | [typeof PatchRoot];
export declare function diff<T>(input: T[], output: T[]): PatchArray<T>[] | [typeof PatchRoot];
export declare function diff<T, R>(input: T[], output: T[], options?: DiffOptions<T, R>): PatchArray<T>[] | [typeof PatchRoot];
//# sourceMappingURL=diff.d.ts.map