@domql/state 2.5.193 → 2.5.197

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.
@@ -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.preventUpdate)
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
- const result = setByPath(...change.slice(1), { preventUpdate: true });
165
- return (0, import_utils.overwriteDeep)(acc, result);
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] === "remove") {
168
+ removeByPath.call(state, change[1], options);
169
+ }
170
+ return acc;
166
171
  }, {});
167
172
  return state.update(update, options);
168
173
  };
@@ -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.preventUpdate)
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
- const result = setByPath(...change.slice(1), { preventUpdate: true });
149
- return overwriteDeep(acc, result);
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] === "remove") {
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.preventUpdate) return update
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
- const result = setByPath(...change.slice(1), { preventUpdate: true })
144
- return overwriteDeep(acc, result)
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] === 'remove') {
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.193",
3
+ "version": "2.5.197",
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": "43f57cec4a807f104342f92da621aedcd0b48e3e"
35
+ "gitHead": "15e733d1bd4581ad936ba6614d8936deee098306"
36
36
  }