@constela/runtime 0.18.2 → 0.18.3
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/index.js +6 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -199,12 +199,14 @@ function setValueAtPath(obj, path, value) {
|
|
|
199
199
|
if (path.length === 0) return value;
|
|
200
200
|
const head2 = path[0];
|
|
201
201
|
const rest = path.slice(1);
|
|
202
|
-
const isArrayIndex = typeof head2 === "number";
|
|
203
202
|
let clone3;
|
|
204
|
-
if (
|
|
205
|
-
clone3 =
|
|
203
|
+
if (Array.isArray(obj)) {
|
|
204
|
+
clone3 = [...obj];
|
|
205
|
+
} else if (obj != null && typeof obj === "object") {
|
|
206
|
+
clone3 = { ...obj };
|
|
206
207
|
} else {
|
|
207
|
-
|
|
208
|
+
const isArrayIndex = typeof head2 === "number" || typeof head2 === "string" && /^\d+$/.test(head2);
|
|
209
|
+
clone3 = isArrayIndex ? [] : {};
|
|
208
210
|
}
|
|
209
211
|
const objRecord = obj;
|
|
210
212
|
clone3[head2] = setValueAtPath(
|