mol_plot_all 1.2.1401 → 1.2.1402
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/node.d.ts +5 -0
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +26 -11
- package/node.js.map +1 -1
- package/node.mjs +26 -11
- package/node.test.js +115 -36
- package/node.test.js.map +1 -1
- package/package.json +2 -1
package/node.js
CHANGED
|
@@ -1256,6 +1256,16 @@ var $;
|
|
|
1256
1256
|
$.$mol_tree2_to_string = $mol_tree2_to_string;
|
|
1257
1257
|
})($ || ($ = {}));
|
|
1258
1258
|
|
|
1259
|
+
;
|
|
1260
|
+
"use strict";
|
|
1261
|
+
var $;
|
|
1262
|
+
(function ($) {
|
|
1263
|
+
function $mol_maybe(value) {
|
|
1264
|
+
return (value == null) ? [] : [value];
|
|
1265
|
+
}
|
|
1266
|
+
$.$mol_maybe = $mol_maybe;
|
|
1267
|
+
})($ || ($ = {}));
|
|
1268
|
+
|
|
1259
1269
|
;
|
|
1260
1270
|
"use strict";
|
|
1261
1271
|
var $;
|
|
@@ -1323,33 +1333,38 @@ var $;
|
|
|
1323
1333
|
return $$.$mol_tree2_to_string(this);
|
|
1324
1334
|
}
|
|
1325
1335
|
insert(value, ...path) {
|
|
1336
|
+
return this.update($mol_maybe(value), ...path)[0];
|
|
1337
|
+
}
|
|
1338
|
+
update(value, ...path) {
|
|
1326
1339
|
if (path.length === 0)
|
|
1327
1340
|
return value;
|
|
1328
1341
|
const type = path[0];
|
|
1329
1342
|
if (typeof type === 'string') {
|
|
1330
1343
|
let replaced = false;
|
|
1331
|
-
const sub = this.kids.
|
|
1344
|
+
const sub = this.kids.flatMap((item, index) => {
|
|
1332
1345
|
if (item.type !== type)
|
|
1333
1346
|
return item;
|
|
1334
1347
|
replaced = true;
|
|
1335
|
-
return item.
|
|
1348
|
+
return item.update(value, ...path.slice(1));
|
|
1336
1349
|
}).filter(Boolean);
|
|
1337
1350
|
if (!replaced && value) {
|
|
1338
|
-
sub.push(this.struct(type, []).
|
|
1351
|
+
sub.push(...this.struct(type, []).update(value, ...path.slice(1)));
|
|
1339
1352
|
}
|
|
1340
|
-
return this.clone(sub);
|
|
1353
|
+
return [this.clone(sub)];
|
|
1341
1354
|
}
|
|
1342
1355
|
else if (typeof type === 'number') {
|
|
1343
|
-
const
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1356
|
+
const ins = (this.kids[type] || this.list([]))
|
|
1357
|
+
.update(value, ...path.slice(1));
|
|
1358
|
+
return [this.clone([
|
|
1359
|
+
...this.kids.slice(0, type),
|
|
1360
|
+
...ins,
|
|
1361
|
+
...this.kids.slice(type + 1),
|
|
1362
|
+
])];
|
|
1347
1363
|
}
|
|
1348
1364
|
else {
|
|
1349
1365
|
const kids = ((this.kids.length === 0) ? [this.list([])] : this.kids)
|
|
1350
|
-
.
|
|
1351
|
-
|
|
1352
|
-
return this.clone(kids);
|
|
1366
|
+
.flatMap(item => item.update(value, ...path.slice(1)));
|
|
1367
|
+
return [this.clone(kids)];
|
|
1353
1368
|
}
|
|
1354
1369
|
}
|
|
1355
1370
|
select(...path) {
|