UNPKG

2 kBTypeScriptView Raw
1import { Pointer } from './pointer';
2export { Pointer };
3import { Operation, TestOperation, VoidableDiff } from './diff';
4export { Operation, TestOperation };
5export type Patch = Operation[];
6/**
7Apply a 'application/json-patch+json'-type patch to an object.
8
9`patch` *must* be an array of operations.
10
11> Operation objects MUST have exactly one "op" member, whose value
12> indicates the operation to perform. Its value MUST be one of "add",
13> "remove", "replace", "move", "copy", or "test"; other values are
14> errors.
15
16This method mutates the target object in-place.
17
18@returns list of results, one for each operation: `null` indicated success,
19 otherwise, the result will be an instance of one of the Error classes:
20 MissingError, InvalidOperationError, or TestError.
21*/
22export declare function applyPatch(object: any, patch: Operation[]): (import("./patch").MissingError | import("./patch").TestError | import("./patch").InvalidOperationError | null)[];
23/**
24Produce a 'application/json-patch+json'-type patch to get from one object to
25another.
26
27This does not alter `input` or `output` unless they have a property getter with
28side-effects (which is not a good idea anyway).
29
30`diff` is called on each pair of comparable non-primitive nodes in the
31`input`/`output` object trees, producing nested patches. Return `undefined`
32to fall back to default behaviour.
33
34Returns list of operations to perform on `input` to produce `output`.
35*/
36export declare function createPatch(input: any, output: any, diff?: VoidableDiff): Operation[];
37/**
38Produce an 'application/json-patch+json'-type list of tests, to verify that
39existing values in an object are identical to the those captured at some
40checkpoint (whenever this function is called).
41
42This does not alter `input` or `output` unless they have a property getter with
43side-effects (which is not a good idea anyway).
44
45Returns list of test operations.
46*/
47export declare function createTests(input: any, patch: Operation[]): TestOperation[];