-
Notifications
You must be signed in to change notification settings - Fork 535
Expand file tree
/
Copy patharray.ts
More file actions
55 lines (50 loc) · 1.41 KB
/
Copy patharray.ts
File metadata and controls
55 lines (50 loc) · 1.41 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import Diff from './base.js';
import type {ChangeObject, DiffArraysOptionsNonabortable, CallbackOptionNonabortable, DiffArraysOptionsAbortable, DiffCallbackNonabortable, CallbackOptionAbortable} from '../types.js';
class ArrayDiff<T> extends Diff<T, Array<T>> {
tokenize(value: Array<T>) {
return value.slice();
}
join(value: Array<T>) {
return value;
}
removeEmpty(value: Array<T>) {
return value;
}
}
export const arrayDiff = new ArrayDiff();
/**
* diffs two arrays of tokens, comparing each item for strict equality (===).
* @returns a list of change objects.
*/
export function diffArrays<T>(
oldArr: T[],
newArr: T[],
options: DiffCallbackNonabortable<T[]>
): undefined;
export function diffArrays<T>(
oldArr: T[],
newArr: T[],
options: DiffArraysOptionsAbortable<T> & CallbackOptionAbortable<T[]>
): undefined
export function diffArrays<T>(
oldArr: T[],
newArr: T[],
options: DiffArraysOptionsNonabortable<T> & CallbackOptionNonabortable<T[]>
): undefined
export function diffArrays<T>(
oldArr: T[],
newArr: T[],
options: DiffArraysOptionsAbortable<T>
): ChangeObject<T[]>[] | undefined
export function diffArrays<T>(
oldArr: T[],
newArr: T[],
options?: DiffArraysOptionsNonabortable<T>
): ChangeObject<T[]>[]
export function diffArrays<T>(
oldArr: T[],
newArr: T[],
options?: any
): undefined | ChangeObject<T[]>[] {
return arrayDiff.diff(oldArr, newArr, options);
}