@domql/state 2.5.193 → 2.5.198
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/dist/cjs/methods.js +8 -3
- package/dist/esm/methods.js +8 -3
- package/methods.js +8 -3
- package/package.json +2 -2
package/dist/cjs/methods.js
CHANGED
|
@@ -154,15 +154,20 @@ const setByPath = function(path, val, options = {}) {
|
|
|
154
154
|
const value = (0, import_utils.deepClone)(val);
|
|
155
155
|
(0, import_utils.setInObjectByPath)(state, path, val);
|
|
156
156
|
const update = (0, import_utils.createNestedObject)(path, value);
|
|
157
|
-
if (options.
|
|
157
|
+
if (options.preventStateUpdate)
|
|
158
158
|
return update;
|
|
159
159
|
return state.update(update, options);
|
|
160
160
|
};
|
|
161
161
|
const setPathCollection = function(changes, options = {}) {
|
|
162
162
|
const state = this;
|
|
163
163
|
const update = changes.reduce((acc, change) => {
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
if (change[0] === "update") {
|
|
165
|
+
const result = setByPath.call(state, change[1], change[2], { preventStateUpdate: true });
|
|
166
|
+
return (0, import_utils.overwriteDeep)(acc, result);
|
|
167
|
+
} else if (change[0] === "delete") {
|
|
168
|
+
removeByPath.call(state, change[1], options);
|
|
169
|
+
}
|
|
170
|
+
return acc;
|
|
166
171
|
}, {});
|
|
167
172
|
return state.update(update, options);
|
|
168
173
|
};
|
package/dist/esm/methods.js
CHANGED
|
@@ -138,15 +138,20 @@ const setByPath = function(path, val, options = {}) {
|
|
|
138
138
|
const value = deepClone(val);
|
|
139
139
|
setInObjectByPath(state, path, val);
|
|
140
140
|
const update = createNestedObject(path, value);
|
|
141
|
-
if (options.
|
|
141
|
+
if (options.preventStateUpdate)
|
|
142
142
|
return update;
|
|
143
143
|
return state.update(update, options);
|
|
144
144
|
};
|
|
145
145
|
const setPathCollection = function(changes, options = {}) {
|
|
146
146
|
const state = this;
|
|
147
147
|
const update = changes.reduce((acc, change) => {
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
if (change[0] === "update") {
|
|
149
|
+
const result = setByPath.call(state, change[1], change[2], { preventStateUpdate: true });
|
|
150
|
+
return overwriteDeep(acc, result);
|
|
151
|
+
} else if (change[0] === "delete") {
|
|
152
|
+
removeByPath.call(state, change[1], options);
|
|
153
|
+
}
|
|
154
|
+
return acc;
|
|
150
155
|
}, {});
|
|
151
156
|
return state.update(update, options);
|
|
152
157
|
};
|
package/methods.js
CHANGED
|
@@ -133,15 +133,20 @@ export const setByPath = function (path, val, options = {}) {
|
|
|
133
133
|
const value = deepClone(val)
|
|
134
134
|
setInObjectByPath(state, path, val)
|
|
135
135
|
const update = createNestedObject(path, value)
|
|
136
|
-
if (options.
|
|
136
|
+
if (options.preventStateUpdate) return update
|
|
137
137
|
return state.update(update, options)
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
export const setPathCollection = function (changes, options = {}) {
|
|
141
141
|
const state = this
|
|
142
142
|
const update = changes.reduce((acc, change) => {
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
if (change[0] === 'update') {
|
|
144
|
+
const result = setByPath.call(state, change[1], change[2], { preventStateUpdate: true })
|
|
145
|
+
return overwriteDeep(acc, result)
|
|
146
|
+
} else if (change[0] === 'delete') {
|
|
147
|
+
removeByPath.call(state, change[1], options)
|
|
148
|
+
}
|
|
149
|
+
return acc
|
|
145
150
|
}, {})
|
|
146
151
|
return state.update(update, options)
|
|
147
152
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/state",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.198",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"@domql/report": "^2.5.186",
|
|
33
33
|
"@domql/utils": "^2.5.187"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "045032f5c80a92a1a05b0dfff68c93c9b32e6bd9"
|
|
36
36
|
}
|