This repository was archived by the owner on Oct 17, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +33
-13
lines changed Expand file tree Collapse file tree 1 file changed +33
-13
lines changed Original file line number Diff line number Diff line change 18
18
A small library that can deep diff two JavaScript Objects, including nested structures of arrays and objects.
19
19
20
20
## Installation
21
- ` yarn add deep-object-diff `
22
-
23
- ` npm i --save deep-object-diff `
21
+ ` yarn add https://github.com/sanukerinc/deep-object-diff.git `
24
22
25
23
## Functions available:
26
24
- [ ` diff(originalObj, updatedObj) ` ] ( #diff )
@@ -139,9 +137,13 @@ console.log(addedDiff(lhs, rhs));
139
137
foo: {
140
138
bar: {
141
139
c: {
142
- '2': 'z'
140
+ '2': {
141
+ after: 'z'
142
+ }
143
143
},
144
- d: 'Hello, world!'
144
+ d: {
145
+ after: 'Hello, world!'
146
+ }
145
147
}
146
148
}
147
149
}
@@ -181,9 +183,13 @@ console.log(deletedDiff(lhs, rhs));
181
183
foo: {
182
184
bar: {
183
185
a: {
184
- '1': undefined
186
+ '1': {
187
+ before: 'b'
188
+ }
185
189
},
186
- e: undefined
190
+ e: {
191
+ before: 'Hello, world!'
192
+ }
187
193
}
188
194
}
189
195
}
@@ -220,7 +226,10 @@ console.log(updatedDiff(lhs, rhs));
220
226
221
227
/*
222
228
{
223
- buzz: 'fizz'
229
+ buzz: {
230
+ before: 'world'
231
+ after: 'fizz'
232
+ }
224
233
}
225
234
*/
226
235
```
@@ -259,24 +268,35 @@ console.log(detailedDiff(lhs, rhs));
259
268
foo: {
260
269
bar: {
261
270
c: {
262
- '2': 'z'
271
+ '2': {
272
+ after: 'z'
273
+ }
263
274
},
264
- d: 'Hello, world!'
275
+ d: {
276
+ after: 'Hello, world!'
277
+ }
265
278
}
266
279
}
267
280
},
268
281
deleted: {
269
282
foo: {
270
283
bar: {
271
284
a: {
272
- '1': undefined
285
+ '1': {
286
+ before: 'b'
287
+ }
273
288
},
274
- e: undefined
289
+ e: {
290
+ before: 100
291
+ }
275
292
}
276
293
}
277
294
},
278
295
updated: {
279
- buzz: 'fizz'
296
+ buzz: {
297
+ before: 'world'
298
+ after: 'fizz'
299
+ }
280
300
}
281
301
}
282
302
*/
You can’t perform that action at this time.
0 commit comments