@solid-primitives/deep 0.2.8 → 0.2.10
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/README.md +4 -4
- package/dist/index.cjs +3 -6
- package/dist/index.js +3 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
Primitives for tracking and observing nested reactive objects in Solid.
|
|
13
13
|
|
|
14
|
-
- [`trackDeep`](#
|
|
15
|
-
- [`trackStore`](#
|
|
16
|
-
- [`captureStoreUpdates`](#
|
|
14
|
+
- [`trackDeep`](#trackdeep) - Tracks all properties of a store by iterating over them recursively.
|
|
15
|
+
- [`trackStore`](#trackstore) - A more performant alternative to `trackDeep` utilizing specific store implementations.
|
|
16
|
+
- [`captureStoreUpdates`](#capturestoreupdates) - A utility function that captures all updates to a store and returns them as an array.
|
|
17
17
|
|
|
18
18
|
## Installation
|
|
19
19
|
|
|
@@ -121,7 +121,7 @@ setState("todos", ["foo"]);
|
|
|
121
121
|
getDelta(); // [{ path: ["todos"], value: ["foo"] }]
|
|
122
122
|
```
|
|
123
123
|
|
|
124
|
-
The returned function will track all updates to a store (just like [`trackStore`](#
|
|
124
|
+
The returned function will track all updates to a store (just like [`trackStore`](#trackstore)), so it can be used inside a tracking scope.
|
|
125
125
|
|
|
126
126
|
```ts
|
|
127
127
|
const [state, setState] = createStore({ todos: [] });
|
package/dist/index.cjs
CHANGED
|
@@ -15,8 +15,7 @@ function traverse(value, seen) {
|
|
|
15
15
|
let proto;
|
|
16
16
|
if (value != null && typeof value === "object" && !seen.has(value) && ((isArray = Array.isArray(value)) || value[solidJs.$PROXY] || !(proto = Object.getPrototypeOf(value)) || proto === Object.prototype)) {
|
|
17
17
|
seen.add(value);
|
|
18
|
-
for (const child of isArray ? value : Object.values(value))
|
|
19
|
-
traverse(child, seen);
|
|
18
|
+
for (const child of isArray ? value : Object.values(value)) traverse(child, seen);
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
exports.deepTrack = trackDeep;
|
|
@@ -107,16 +106,14 @@ var SeenNodes;
|
|
|
107
106
|
function newCacheNode(children) {
|
|
108
107
|
const record = { ...children };
|
|
109
108
|
for (const [key, node] of entries(children)) {
|
|
110
|
-
if (SeenNodes.has(node))
|
|
111
|
-
continue;
|
|
109
|
+
if (SeenNodes.has(node)) continue;
|
|
112
110
|
SeenNodes.add(node);
|
|
113
111
|
record[key] = newCacheNode(getStoreNodechildren(node));
|
|
114
112
|
}
|
|
115
113
|
return { children, record };
|
|
116
114
|
}
|
|
117
115
|
function compareStoreWithCache(node, parent, key, path) {
|
|
118
|
-
if (SeenNodes.has(node))
|
|
119
|
-
return;
|
|
116
|
+
if (SeenNodes.has(node)) return;
|
|
120
117
|
SeenNodes.add(node);
|
|
121
118
|
const cacheNode = parent[key], children = getStoreNodechildren(node);
|
|
122
119
|
if (cacheNode && children === cacheNode.children) {
|
package/dist/index.js
CHANGED
|
@@ -13,8 +13,7 @@ function traverse(value, seen) {
|
|
|
13
13
|
let proto;
|
|
14
14
|
if (value != null && typeof value === "object" && !seen.has(value) && ((isArray = Array.isArray(value)) || value[$PROXY] || !(proto = Object.getPrototypeOf(value)) || proto === Object.prototype)) {
|
|
15
15
|
seen.add(value);
|
|
16
|
-
for (const child of isArray ? value : Object.values(value))
|
|
17
|
-
traverse(child, seen);
|
|
16
|
+
for (const child of isArray ? value : Object.values(value)) traverse(child, seen);
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
var deepTrack = trackDeep;
|
|
@@ -105,16 +104,14 @@ var SeenNodes;
|
|
|
105
104
|
function newCacheNode(children) {
|
|
106
105
|
const record = { ...children };
|
|
107
106
|
for (const [key, node] of entries(children)) {
|
|
108
|
-
if (SeenNodes.has(node))
|
|
109
|
-
continue;
|
|
107
|
+
if (SeenNodes.has(node)) continue;
|
|
110
108
|
SeenNodes.add(node);
|
|
111
109
|
record[key] = newCacheNode(getStoreNodechildren(node));
|
|
112
110
|
}
|
|
113
111
|
return { children, record };
|
|
114
112
|
}
|
|
115
113
|
function compareStoreWithCache(node, parent, key, path) {
|
|
116
|
-
if (SeenNodes.has(node))
|
|
117
|
-
return;
|
|
114
|
+
if (SeenNodes.has(node)) return;
|
|
118
115
|
SeenNodes.add(node);
|
|
119
116
|
const cacheNode = parent[key], children = getStoreNodechildren(node);
|
|
120
117
|
if (cacheNode && children === cacheNode.children) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solid-primitives/deep",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"description": "Primitives for tracking and observing nested reactive objects in Solid.",
|
|
5
5
|
"author": "Samuel Burbano <me@iosamuel.dev>",
|
|
6
6
|
"contributors": [
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"typesVersions": {},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@solid-primitives/memo": "^1.3.
|
|
58
|
+
"@solid-primitives/memo": "^1.3.10"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"solid-js": "^1.6.12"
|