Class: JSONPatch ​
Defined in: packages/common/src/json-patch.ts:13
Thin wrapper around fast-json-patch to keep a stable API within this package. JSONPatch
Constructors ​
Constructor ​
new JSONPatch():
JSONPatch
Returns ​
JSONPatch
Methods ​
apply() ​
staticapply(sourceDocument,operations,options?):Record<any,any>
Defined in: packages/common/src/json-patch.ts:21
Applies a JSON Patch to a source document and returns the patched document. Does not mutate the input document.
Parameters ​
sourceDocument ​
Record<any, any>
The source JSON document to apply the patch to.
operations ​
The JSON Patch operations to apply.
options? ​
clone? ​
(value) => any
mutate? ​
boolean
Returns ​
Record<any, any>
The patched JSON document.
diff() ​
staticdiff(sourceDocument,targetDocument,path?):PatchOperation[]
Defined in: packages/common/src/json-patch.ts:51
Compute a JSON Patch diff from source => target.
Parameters ​
sourceDocument ​
The source JSON document.
targetDocument ​
The target JSON document.
path? ​
string = ''
An optional base path to prefix to each operation.
Returns ​
The computed JSON Patch operations.
escapeSegmentPath() ​
staticescapeSegmentPath(pointer):string
Defined in: packages/common/src/json-patch.ts:79
Escape a JSON Pointer segment according to RFC 6901.
Parameters ​
pointer ​
string
The JSON Pointer to escape.
Returns ​
string
The escaped JSON Pointer.
joinPointer() ​
staticjoinPointer(prefix,opPath):string
Defined in: packages/common/src/json-patch.ts:68
Join a base pointer prefix with an operation path ensuring correct escaping.
Parameters ​
prefix ​
string
The base pointer prefix.
opPath ​
string
The operation path.
Returns ​
string
The joined pointer.
validateOperations() ​
staticvalidateOperations(operations):Error|null
Defined in: packages/common/src/json-patch.ts:91
Validate JSON Patch operations.
Parameters ​
operations ​
The operations to validate.
Returns ​
Error | null
An Error if validation fails, otherwise null.