Class: Patch ​
Defined in: packages/common/src/patch.ts:15
Implementation of IETF RFC 6902 JSON Patch.
JavaScript Object Notation (JSON) Patch defines a JSON document structure for expressing a sequence of operations to apply to a JavaScript Object Notation (JSON) document; it is suitable for use with the HTTP PATCH method. The "application/json-patch+json" media type is used to identify such patch documents.
Patch
Constructors ​
Constructor ​
new Patch():
Patch
Returns ​
Patch
Methods ​
apply() ​
apply(
sourceDocument,operations):JSONObject
Defined in: packages/common/src/patch.ts:23
Applies a JSON Patch to a source document and returns the patched document.
Parameters ​
sourceDocument ​
The source document to patch.
operations ​
The JSON Patch operations to apply.
Returns ​
The patched document.
Throws ​
If an unsupported operation is provided.
create() ​
create(
patches):PatchOperation[]
Defined in: packages/common/src/patch.ts:82
Constructs a JSON Patch with a single operation (e.g. add service).
Parameters ​
patches ​
The patch operation to create.
Returns ​
A single-entry JSON Patch array.
diff() ​
diff(
sourceDocument,targetDocument,path):PatchOperation[]
Defined in: packages/common/src/patch.ts:104
Find the diff between a source and target document constructing the patch operations from source => target.
Parameters ​
sourceDocument ​
The original JSON object.
targetDocument ​
The target JSON object to transform into.
path ​
string
Returns ​
An array of JSON Patch operations.