-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple-diff.d.ts
35 lines (29 loc) · 885 Bytes
/
simple-diff.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
declare function diff(oldObj: any, newObj: any, ops?: DiffOptions): DiffEvent[];
export default diff;
export interface DiffOptions extends Partial<PathChange> {
idProp?: string,
idProps?: {[path: string]: string},
addEvent?: string,
removeEvent?: string,
changeEvent?: string,
addItemEvent?: string,
removeItemEvent?: string,
moveItemEvent?: string,
callback?: (event: DiffEvent) => void,
comparators?: Array<[any, Comparator]>,
ignore?: Comparator,
}
export type Path = Array<string | number>;
export interface PathChange {
oldPath: Path,
newPath: Path,
}
export type Comparator = (oldValue: any, newValue: any, options: PathChange) => boolean;
export interface DiffEvent extends PathChange {
type: 'add' | 'remove' | 'change' | 'add-item' | 'remove-item' | 'move-item',
oldValue: any,
newValue: any,
oldIndex?: number,
curIndex?: number,
newIndex?: number,
}