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
+136-7Lines changed: 136 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ This library compares two arrays or objects and returns a full diff of their dif
18
18
19
19
Most existing solutions return a confusing diff format that often requires extra parsing. They are also limited to object comparison.
20
20
21
-
**Superdiff** provides a complete and readable diff for both arrays **and** objects. Plus, it's battle-tested, has zero dependencies, and is super fast.
21
+
**Superdiff** provides a complete and readable diff for both arrays **and** objects. Plus, it supports stream and file inputs for handling large datasets efficiently, is battle-tested, has zero dependencies, and is super fast.
22
22
23
23
Import. Enjoy. 👍
24
24
@@ -40,7 +40,7 @@ I am grateful to the generous donors of **Superdiff**!
40
40
41
41
## FEATURES
42
42
43
-
**Superdiff** exports 5 functions:
43
+
**Superdiff** exports 6 functions:
44
44
45
45
```ts
46
46
// Returns a complete diff of two objects
@@ -52,6 +52,9 @@ getListDiff(prevList, nextList)
52
52
// Streams the diff of two object lists, ideal for large lists and maximum performance
Streams the diff of two object lists, ideal for large lists and maximum performance.
@@ -315,14 +321,34 @@ Streams the diff of two object lists, ideal for large lists and maximum performa
315
321
316
322
**Input**
317
323
324
+
#### streamListDiff (server)
325
+
326
+
> In a server environment, `Readable` refers to Node.js streams, and `FilePath` refers to the path of a file (e.g., `./list.json`). Examples are provided in the #usage section below.
showOnly?: ("added"|"deleted"|"moved"|"updated"|"equal")[], // [] by default
324
-
chunksSize?:number, // // 0 by default
325
-
considerMoveAsUpdate?boolean; // false by default
335
+
chunksSize?:number, // 0 by default
336
+
considerMoveAsUpdate?:boolean; // false by default
337
+
}
338
+
```
339
+
340
+
#### streamListDiffClient (browser)
341
+
342
+
> In a browser environment, `ReadableStream` refers to the browser's streaming API, and `File` refers to an uploaded or local file. Examples are provided in the #usage section below.
diff.on("finish", () =>console.log("The full diff is available"))
494
+
diff.on("finish", () => console.log("Your data has been processed. The full diff is available."))
435
495
diff.on("error", (err) => console.log(err))
436
496
```
497
+
498
+
**Using `fetch`**
499
+
500
+
A common use case would be to do a live diff against a stream, in order to avoid loading the entire dataset into memory. Here are two examples, for browser and server use:
0 commit comments