File tree 1 file changed +17
-16
lines changed
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
28
28
29
29
### Applying patches:
30
30
``` js
31
+ jsonmergepatch .apply (obj: Object , patch: Object ) : Object
32
+ ```
33
+ Applies ` patch ` onto source ` obj ` .
34
+
35
+ ### Example:
36
+ ``` js
31
37
var source = {
32
38
" title" : " Goodbye!" ,
33
39
" author" : {
@@ -55,6 +61,12 @@ var target = jsonmergepatch.apply(source, patch);
55
61
56
62
### Generating patches:
57
63
``` 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
58
70
var source = {
59
71
" title" : " Goodbye!" ,
60
72
" author" : " John Doe"
@@ -72,6 +84,11 @@ var patch = jsonmergepatch.generate(source, target);
72
84
// }
73
85
```
74
86
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
+
75
92
76
93
### Usage with Javascript objects
77
94
@@ -107,22 +124,6 @@ var patch = jsonmergepatch.generate(
107
124
// }
108
125
```
109
126
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
-
126
127
## Running tests
127
128
128
129
``` sh
You can’t perform that action at this time.
0 commit comments