File tree Expand file tree Collapse file tree 1 file changed +17
-16
lines changed Expand file tree Collapse file tree 1 file changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,12 @@ $ npm install json-merge-patch --save
2828
2929### Applying patches:
3030``` js
31+ jsonmergepatch .apply (obj: Object , patch: Object ) : Object
32+ ```
33+ Applies ` patch ` onto source ` obj ` .
34+
35+ ### Example:
36+ ``` js
3137var source = {
3238 " title" : " Goodbye!" ,
3339 " author" : {
@@ -55,6 +61,12 @@ var target = jsonmergepatch.apply(source, patch);
5561
5662### Generating patches:
5763``` js
64+ jsonmergepatch .generate (source: Object , target: Object ) : Object
65+ ```
66+ Compares ` source ` and ` target ` object and generates a ` patch ` of the changes necessary to convert ` source ` into ` target ` .
67+
68+ ### Example:
69+ ``` js
5870var source = {
5971 " title" : " Goodbye!" ,
6072 " author" : " John Doe"
@@ -72,6 +84,11 @@ var patch = jsonmergepatch.generate(source, target);
7284// }
7385```
7486
87+ ### Merging patches
88+
89+ This function is ** outside the scope of the RFC** , its purpose is to combine/squash successive patches of the same entity into one patch.
90+ Use it at your own risks.
91+
7592
7693### Usage with Javascript objects
7794
@@ -107,22 +124,6 @@ var patch = jsonmergepatch.generate(
107124// }
108125```
109126
110- ## API
111-
112- #### jsonmergepatch.apply (` obj ` Object, ` patch ` Object) : Object
113-
114- Applies ` patch ` on ` obj ` .
115-
116- #### jsonmergepatch.generate (` source ` Object, ` target ` Object) : ` patch ` Object
117-
118- Generates a ` patch ` Object from source and target Object.
119-
120-
121- #### jsonmergepatch.merge (` patch1 ` Object, ` patch2 ` Object) : ` patch ` Object
122-
123- Generates a ` patch ` Object by merging patch1 and patch2.
124-
125-
126127## Running tests
127128
128129``` sh
You can’t perform that action at this time.
0 commit comments