You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// subDiff is a recursive diff in case of nested subproperties
164
-
subDiff?:Subproperties[];
164
+
subDiff?:SubProperties[];
165
165
}[];
166
166
}[];
167
167
};
168
168
```
169
169
170
+
**Options**
171
+
172
+
```ts
173
+
{
174
+
ignoreArrayOrder?:boolean// false by default,
175
+
showOnly?: {
176
+
statuses: ("added"|"deleted"|"updated"|"equal")[], // [] by default
177
+
granularity?: "basic"|"deep"// basic by default
178
+
}
179
+
}
180
+
```
181
+
182
+
-`ignoreArrayOrder`: if set to `true`, `["hello", "world"]` and `["world", "hello"]` will be considered as `equal`, because the two arrays have the same value, just not in the same order.
183
+
-`showOnly`: gives you the option to only return the values whose status interest you. It has two parameters:
184
+
185
+
-`statuses`: status you want to see in the output (ex: `["added", "equal"]`)
186
+
-`granularity`:
187
+
-`basic` only returns the main properties whose status match your request, without taking into account their eventual subproperties.
188
+
-`deep` return main properties whose status match your request but also their relevant subproperties.
189
+
170
190
### getListDiff()
171
191
172
192
```js
@@ -197,6 +217,16 @@ type ListDiff = {
197
217
};
198
218
```
199
219
220
+
**Options**
221
+
222
+
```ts
223
+
{
224
+
showOnly?: ("added"|"deleted"|"moved"|"updated"|"equal")[], // [] by default
225
+
}
226
+
```
227
+
228
+
-`showOnly` gives you the option to only return the values whose status interest you (ex: `["added", "equal"]`).
229
+
200
230
### isEqual()
201
231
202
232
```js
@@ -205,6 +235,16 @@ import { isEqual } from "@donedeal0/superdiff";
205
235
206
236
Checks if two values are equal.
207
237
238
+
**Options**
239
+
240
+
```ts
241
+
{
242
+
ignoreArrayOrder?:boolean// false by default,
243
+
}
244
+
```
245
+
246
+
-`ignoreArrayOrder`: if set to `true`, `["hello", "world"]` and `["world", "hello"]` will be considered as `equal`, because the two arrays have the same value, just not in the same order.
247
+
208
248
### isObject()
209
249
210
250
```js
@@ -329,25 +369,25 @@ output
329
369
+ status: "updated",
330
370
subPropertiesDiff: [
331
371
{
332
-
name: "name",
372
+
property: "name",
333
373
previousValue: "joe",
334
374
currentValue: "joe",
335
375
status: "equal",
336
376
},
337
377
+ {
338
-
+name: "member",
378
+
+property: "member",
339
379
+ previousValue: true,
340
380
+ currentValue: false,
341
381
+ status: "updated",
342
382
+ },
343
383
+ {
344
-
+name: "hobbies",
384
+
+property: "hobbies",
345
385
+ previousValue: ["golf", "football"],
346
386
+ currentValue: ["golf", "chess"],
347
387
+ status: "updated",
348
388
+ },
349
389
{
350
-
name: "age",
390
+
property: "age",
351
391
previousValue: 66,
352
392
currentValue: 66,
353
393
status: "equal",
@@ -397,25 +437,13 @@ More examples are availble in the tests of the source code.
397
437
398
438
<hr/>
399
439
400
-
### OPTIONS
401
-
402
-
`getObjectDiff()` and `isEqual()` accept a facultative `options` parameter:
403
-
404
-
```ts
405
-
{
406
-
discardArrayOrder?:boolean// false by default
407
-
}
408
-
```
409
-
410
-
If `discardArrayOrder` is set to `true`, `["hello", "world"]` and `["world", "hello"]` will be considered as `equal`, because the two arrays have the same value, just not in the same order.
411
-
412
440
## CREDITS
413
441
414
442
DoneDeal0
415
443
416
444
## SUPPORT
417
445
418
-
If you use Superdiff, please show your support by buying me coffee:
446
+
If you or your company use Superdiff, please show your support by buying me coffee:
0 commit comments