-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsimple-diff.d.ts
More file actions
37 lines (31 loc) · 944 Bytes
/
simple-diff.d.ts
File metadata and controls
37 lines (31 loc) · 944 Bytes
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
36
37
declare function diff(oldObj: any, newObj: any, ops?: diff.DiffOptions): diff.DiffEvent[];
declare namespace 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,
}
}
export = diff;