-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.d.ts
34 lines (33 loc) · 885 Bytes
/
index.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
export type Operation = AddOperation<any> | RemoveOperation | ReplaceOperation<any> | MoveOperation | CopyOperation | TestOperation<any>;
interface BaseOperation {
path: string;
}
interface AddOperation<T> extends BaseOperation {
op: 'add';
value: T;
}
interface RemoveOperation extends BaseOperation {
op: 'remove';
}
interface ReplaceOperation<T> extends BaseOperation {
op: 'replace';
value: T;
}
interface MoveOperation extends BaseOperation {
op: 'move';
from: string;
}
interface CopyOperation extends BaseOperation {
op: 'copy';
from: string;
}
interface TestOperation<T> extends BaseOperation {
op: 'test';
value: T;
}
/**
* Squashes a json-patch patch into a smaller one if possible.
* @param {Array} patch Your input patch
* @returns {Array} The squash patch
*/
export function squash<T>(patch: Operation[]): Operation[];