mnfst 0.5.36 → 0.5.37
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/manifest.data.js +18 -2
- package/package.json +1 -1
package/dist/manifest.data.js
CHANGED
|
@@ -1310,15 +1310,31 @@ function setNestedValue(obj, path, value) {
|
|
|
1310
1310
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
1311
1311
|
const key = keys[i];
|
|
1312
1312
|
const nextKey = keys[i + 1];
|
|
1313
|
+
const nextIsIndex = /^\d+$/.test(nextKey);
|
|
1314
|
+
|
|
1313
1315
|
if (!(key in current)) {
|
|
1314
|
-
current[key] =
|
|
1316
|
+
current[key] = nextIsIndex ? [] : {};
|
|
1317
|
+
} else if (nextIsIndex && !Array.isArray(current[key]) && current[key] && typeof current[key] === 'object') {
|
|
1318
|
+
// If we later discover this container should be an array, coerce numeric-key objects.
|
|
1319
|
+
const existing = current[key];
|
|
1320
|
+
const existingKeys = Object.keys(existing);
|
|
1321
|
+
const numericOnly = existingKeys.every(k => /^\d+$/.test(k));
|
|
1322
|
+
if (numericOnly) {
|
|
1323
|
+
const arr = [];
|
|
1324
|
+
existingKeys.forEach(k => {
|
|
1325
|
+
arr[parseInt(k, 10)] = existing[k];
|
|
1326
|
+
});
|
|
1327
|
+
current[key] = arr;
|
|
1328
|
+
}
|
|
1315
1329
|
}
|
|
1330
|
+
|
|
1316
1331
|
if (Array.isArray(current) && /^\d+$/.test(key)) {
|
|
1317
1332
|
const idx = parseInt(key, 10);
|
|
1318
1333
|
if (current[idx] == null || typeof current[idx] !== 'object') {
|
|
1319
|
-
current[idx] = {};
|
|
1334
|
+
current[idx] = nextIsIndex ? [] : {};
|
|
1320
1335
|
}
|
|
1321
1336
|
}
|
|
1337
|
+
|
|
1322
1338
|
current = current[key];
|
|
1323
1339
|
}
|
|
1324
1340
|
|