strict-diff 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/readme.md +27 -3
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strict-diff",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Tomer Aberbach",
|
|
6
6
|
"email": "tomer@aberba.ch",
|
|
7
7
|
"url": "https://tomeraberba.ch"
|
|
8
8
|
},
|
|
9
|
-
"description": "Find
|
|
9
|
+
"description": "Find all observable difference between two values.",
|
|
10
10
|
"keywords": [
|
|
11
11
|
"deep",
|
|
12
12
|
"diff",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"prettier": "@tomer/prettier-config",
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"builtin-type": "^0.0.
|
|
46
|
+
"builtin-type": "^0.0.5"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@fast-check/vitest": "^0.3.0",
|
package/readme.md
CHANGED
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
</div>
|
|
22
22
|
|
|
23
23
|
<div align="center">
|
|
24
|
-
Find
|
|
24
|
+
Find all observable differences between two values.
|
|
25
25
|
</div>
|
|
26
26
|
|
|
27
27
|
## Features
|
|
28
28
|
|
|
29
|
-
- **Strict:** Finds the most minuscule differences between values
|
|
30
|
-
- **Structured:**
|
|
29
|
+
- **Strict:** Finds the most minuscule differences between values
|
|
30
|
+
- **Structured:** Diff objects have paths and left vs right values
|
|
31
31
|
- **Lazy:** Returns a lazy iterable over the diffs
|
|
32
32
|
|
|
33
33
|
## Install
|
|
@@ -87,6 +87,30 @@ console.log([...strictDiff(left, { a: 1 })])
|
|
|
87
87
|
// },
|
|
88
88
|
// ]
|
|
89
89
|
|
|
90
|
+
// Reference structure diff (shared object used at different positions)
|
|
91
|
+
const shared1 = {}
|
|
92
|
+
const shared2 = {}
|
|
93
|
+
const leftArray = [shared1, shared2, shared1, shared2]
|
|
94
|
+
const rightArray = [shared1, shared2, shared1, shared1]
|
|
95
|
+
console.log([...strictDiff(leftArray, rightArray)])
|
|
96
|
+
//=> [
|
|
97
|
+
// {
|
|
98
|
+
// kind: 'reference',
|
|
99
|
+
// path: [
|
|
100
|
+
// { kind: 'property', index: 3, key: 3 },
|
|
101
|
+
// { kind: 'internal-slot', slot: 'Value' },
|
|
102
|
+
// ],
|
|
103
|
+
// leftFirstSeenPath: [
|
|
104
|
+
// { kind: 'property', index: 1, key: 1 },
|
|
105
|
+
// { kind: 'internal-slot', slot: 'Value' },
|
|
106
|
+
// ],
|
|
107
|
+
// rightFirstSeenPath: [
|
|
108
|
+
// { kind: 'property', index: 0, key: 0 },
|
|
109
|
+
// { kind: 'internal-slot', slot: 'Value' },
|
|
110
|
+
// ],
|
|
111
|
+
// },
|
|
112
|
+
// ]
|
|
113
|
+
|
|
90
114
|
// Lazily iterated
|
|
91
115
|
const diffs = strictDiff({ a: 1, b: 2 }, { a: 99, b: 99 })
|
|
92
116
|
const [firstDiff] = diffs
|