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
Copy file name to clipboardExpand all lines: README.md
+29-33Lines changed: 29 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,19 +6,10 @@ This library compares two arrays or objects and return a complete diff of their
6
6
7
7
## WHY YOU SHOULD USE THIS LIB
8
8
9
-
All other existing solutions return a weird diff format which often require an additional parsing. They are also slow and limited to object comparison. 👎
9
+
All other existing solutions return a weird diff format which often require an additional parsing. They are also limited to object comparison. 👎
10
10
11
11
**Superdiff** gives you a complete diff for both array <u>and</u> objects with a very readable format. Last but not least, it's battled tested and super fast. Import. Enjoy. 👍
12
12
13
-
**Benchmark**:
14
-
15
-
| Objects | Deep-diff 🐢 | Superdiff ⚡ |
16
-
| --------- | ------------ | ------------ |
17
-
| 1.000 | 10.47ms | 5.73ms |
18
-
| 10.000 | 43.05ms | 18.60ms |
19
-
| 100.000 | 289.71ms | 50.96ms |
20
-
| 1.000.000 | 2786.70ms | 389.78ms |
21
-
22
13
## DIFF FORMAT COMPARISON
23
14
24
15
Let's compare the diff format of **Superdiff** and **Deep-diff**, the most popular diff lib on npm:
// subDiff is a recursive diff in case of nested subproperties
164
154
subDiff?:SubProperties[];
165
155
}[];
@@ -169,23 +159,25 @@ type ObjectDiff = {
169
159
170
160
**Options**
171
161
162
+
You can add a third `options` parameter to `getObjectDiff`.
163
+
172
164
```ts
173
165
{
174
166
ignoreArrayOrder?:boolean// false by default,
175
167
showOnly?: {
176
168
statuses: ("added"|"deleted"|"updated"|"equal")[], // [] by default
177
-
granularity?: "basic"|"deep"// basic by default
169
+
granularity?: "basic"|"deep"//"basic" by default
178
170
}
179
171
}
180
172
```
181
173
182
174
-`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:
175
+
-`showOnly`: only returns the values whose status interest you. It has two parameters:
184
176
185
177
-`statuses`: status you want to see in the output (ex: `["added", "equal"]`)
186
178
-`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.
179
+
-`basic` only returns the main properties whose status match your request.
180
+
-`deep`can return main properties if some of their subproperties' status match your request. The subproperties will be filtered accordingly.
189
181
190
182
### getListDiff()
191
183
@@ -219,6 +211,8 @@ type ListDiff = {
219
211
220
212
**Options**
221
213
214
+
You can add a third `options` parameter to `getListDiff`.
215
+
222
216
```ts
223
217
{
224
218
showOnly?: ("added"|"deleted"|"moved"|"updated"|"equal")[], // [] by default
@@ -237,6 +231,8 @@ Checks if two values are equal.
237
231
238
232
**Options**
239
233
234
+
You can add a third `options` parameter to `isEqual`.
235
+
240
236
```ts
241
237
{
242
238
ignoreArrayOrder?:boolean// false by default,
@@ -433,7 +429,7 @@ output
433
429
false;
434
430
```
435
431
436
-
More examples are availble in the tests of the source code.
432
+
More examples are available in the tests of the source code.
437
433
438
434
<hr/>
439
435
@@ -443,7 +439,7 @@ DoneDeal0
443
439
444
440
## SUPPORT
445
441
446
-
If you or your company use Superdiff, please show your support by buying me coffee:
442
+
If you or your company use Superdiff, please show your support by buying me a coffee:
Copy file name to clipboardExpand all lines: package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
{
2
2
"name": "@donedeal0/superdiff",
3
-
"version": "1.0.9",
3
+
"version": "1.0.8",
4
4
"description": "SuperDiff checks the changes between two objects or arrays. It returns a complete diff with relevant information for each property or piece of data",
0 commit comments