Skip to content

Commit a7a0ef4

Browse files
committed
feat: handle stream and file inputs
1 parent 82780cc commit a7a0ef4

File tree

13 files changed

+1908
-356
lines changed

13 files changed

+1908
-356
lines changed

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ I am grateful to the generous donors of **Superdiff**!
4040

4141
## FEATURES
4242

43-
**Superdiff** exports 5 functions:
43+
**Superdiff** exports 6 functions:
4444

4545
```ts
4646
// Returns a complete diff of two objects
@@ -52,6 +52,9 @@ getListDiff(prevList, nextList)
5252
// Streams the diff of two object lists, ideal for large lists and maximum performance
5353
streamListDiff(prevList, nextList, referenceProperty)
5454

55+
// Similar to streamListDiff, but for browser use
56+
streamListDiffClient(prevList, nextList, referenceProperty)
57+
5558
// Checks whether two values are equal
5659
isEqual(dataA, dataB)
5760

@@ -306,7 +309,10 @@ getListDiff(
306309
### streamListDiff()
307310

308311
```js
312+
// If you are in a server environment
309313
import { streamListDiff } from "@donedeal0/superdiff";
314+
// If you are in a browser environment
315+
import { streamListDiffClient } from "@donedeal0/superdiff";
310316
```
311317

312318
Streams the diff of two object lists, ideal for large lists and maximum performance.
@@ -316,8 +322,8 @@ Streams the diff of two object lists, ideal for large lists and maximum performa
316322
**Input**
317323

318324
```ts
319-
prevList: Record<string, unknown>[],
320-
nextList: Record<string, unknown>[],
325+
prevList: Readable | FilePath | Record<string, unknown>[],
326+
nextList: Readable | FilePath | Record<string, unknown>[],
321327
referenceProperty: keyof Record<string, unknown>,
322328
options: {
323329
showOnly?: ("added" | "deleted" | "moved" | "updated" | "equal")[], // [] by default
@@ -370,6 +376,18 @@ type StreamListDiff<T extends Record<string, unknown>> = {
370376
371377
**Input**
372378
379+
You can send streams, file paths, or arrays as input:
380+
381+
```ts
382+
// If you are in a server environment
383+
const streamA = Readable.from(list, { objectMode: true });
384+
const streamB = path.resolve(__dirname, "./list.json");
385+
const streamC = [{ id: 1, name: "hello" }]
386+
387+
// If you are in a browser environment
388+
const streamC = [{ id: 1, name: "hello" }]
389+
```
390+
373391
```diff
374392
const diff = streamListDiff(
375393
[

0 commit comments

Comments
 (0)