mol_tree2 1.0.224 → 1.0.226
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.deps.json +1 -1
- package/node.js +4 -0
- package/node.js.map +1 -1
- package/node.mjs +4 -0
- package/node.mjs.map +1 -1
- package/node.test.js +65 -449
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.deps.json +1 -1
- package/web.js +4 -0
- package/web.js.map +1 -1
- package/web.mjs +4 -0
- package/web.mjs.map +1 -1
- package/web.test.js +1 -0
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -575,6 +575,10 @@ var $;
|
|
|
575
575
|
const sub = json.map(json => $mol_tree2_from_json(json, span));
|
|
576
576
|
return new $mol_tree2('/', '', sub, span);
|
|
577
577
|
}
|
|
578
|
+
if (ArrayBuffer.isView(json)) {
|
|
579
|
+
const buf = new Uint8Array(json.buffer, json.byteOffset, json.byteLength);
|
|
580
|
+
return $mol_tree2.data(String.fromCharCode(...buf), [], span);
|
|
581
|
+
}
|
|
578
582
|
if (json instanceof Date) {
|
|
579
583
|
return new $mol_tree2('', json.toISOString(), [], span);
|
|
580
584
|
}
|
|
@@ -1533,7 +1537,8 @@ var $;
|
|
|
1533
1537
|
return function $mol_log3_logger(event) {
|
|
1534
1538
|
if (!event.time)
|
|
1535
1539
|
event = { time: new Date().toISOString(), ...event };
|
|
1536
|
-
|
|
1540
|
+
let tree = this.$mol_tree2_from_json(event);
|
|
1541
|
+
tree = tree.struct(type, tree.kids);
|
|
1537
1542
|
let str = color(tree.toString());
|
|
1538
1543
|
this.console[level](str);
|
|
1539
1544
|
const self = this;
|
|
@@ -2376,396 +2381,6 @@ var $;
|
|
|
2376
2381
|
;
|
|
2377
2382
|
"use strict";
|
|
2378
2383
|
var $;
|
|
2379
|
-
(function ($) {
|
|
2380
|
-
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
2381
|
-
class $mol_tree extends $mol_object2 {
|
|
2382
|
-
type;
|
|
2383
|
-
data;
|
|
2384
|
-
sub;
|
|
2385
|
-
baseUri;
|
|
2386
|
-
row;
|
|
2387
|
-
col;
|
|
2388
|
-
length;
|
|
2389
|
-
constructor(config = {}) {
|
|
2390
|
-
super();
|
|
2391
|
-
this.type = config.type || '';
|
|
2392
|
-
if (config.value !== undefined) {
|
|
2393
|
-
var sub = $mol_tree.values(config.value);
|
|
2394
|
-
if (config.type || sub.length > 1) {
|
|
2395
|
-
this.sub = [...sub, ...(config.sub || [])];
|
|
2396
|
-
this.data = config.data || '';
|
|
2397
|
-
}
|
|
2398
|
-
else {
|
|
2399
|
-
this.data = sub[0].data;
|
|
2400
|
-
this.sub = config.sub || [];
|
|
2401
|
-
}
|
|
2402
|
-
}
|
|
2403
|
-
else {
|
|
2404
|
-
this.data = config.data || '';
|
|
2405
|
-
this.sub = config.sub || [];
|
|
2406
|
-
}
|
|
2407
|
-
this.baseUri = config.baseUri || '';
|
|
2408
|
-
this.row = config.row || 0;
|
|
2409
|
-
this.col = config.col || 0;
|
|
2410
|
-
this.length = config.length || 0;
|
|
2411
|
-
}
|
|
2412
|
-
static values(str, baseUri) {
|
|
2413
|
-
return str.split('\n').map((data, index) => new $mol_tree({
|
|
2414
|
-
data: data,
|
|
2415
|
-
baseUri: baseUri,
|
|
2416
|
-
row: index + 1,
|
|
2417
|
-
length: data.length,
|
|
2418
|
-
}));
|
|
2419
|
-
}
|
|
2420
|
-
clone(config = {}) {
|
|
2421
|
-
return new $mol_tree({
|
|
2422
|
-
type: ('type' in config) ? config.type : this.type,
|
|
2423
|
-
data: ('data' in config) ? config.data : this.data,
|
|
2424
|
-
sub: ('sub' in config) ? config.sub : this.sub,
|
|
2425
|
-
baseUri: ('baseUri' in config) ? config.baseUri : this.baseUri,
|
|
2426
|
-
row: ('row' in config) ? config.row : this.row,
|
|
2427
|
-
col: ('col' in config) ? config.col : this.col,
|
|
2428
|
-
length: ('length' in config) ? config.length : this.length,
|
|
2429
|
-
value: config.value
|
|
2430
|
-
});
|
|
2431
|
-
}
|
|
2432
|
-
make(config) {
|
|
2433
|
-
return new $mol_tree({
|
|
2434
|
-
baseUri: this.baseUri,
|
|
2435
|
-
row: this.row,
|
|
2436
|
-
col: this.col,
|
|
2437
|
-
length: this.length,
|
|
2438
|
-
...config,
|
|
2439
|
-
});
|
|
2440
|
-
}
|
|
2441
|
-
make_data(value, sub) {
|
|
2442
|
-
return this.make({ value, sub });
|
|
2443
|
-
}
|
|
2444
|
-
make_struct(type, sub) {
|
|
2445
|
-
return this.make({ type, sub });
|
|
2446
|
-
}
|
|
2447
|
-
static fromString(str, baseUri) {
|
|
2448
|
-
var root = new $mol_tree({ baseUri: baseUri });
|
|
2449
|
-
var stack = [root];
|
|
2450
|
-
var row = 0;
|
|
2451
|
-
var prefix = str.replace(/^\n?(\t*)[\s\S]*/, '$1');
|
|
2452
|
-
var lines = str.replace(new RegExp('^\\t{0,' + prefix.length + '}', 'mg'), '').split('\n');
|
|
2453
|
-
lines.forEach(line => {
|
|
2454
|
-
++row;
|
|
2455
|
-
var chunks = /^(\t*)((?:[^\n\t\\ ]+ *)*)(\\[^\n]*)?(.*?)(?:$|\n)/m.exec(line);
|
|
2456
|
-
if (!chunks || chunks[4])
|
|
2457
|
-
return this.$.$mol_fail(new Error(`Syntax error at ${baseUri}:${row}\n${line}`));
|
|
2458
|
-
var indent = chunks[1];
|
|
2459
|
-
var path = chunks[2];
|
|
2460
|
-
var data = chunks[3];
|
|
2461
|
-
var deep = indent.length;
|
|
2462
|
-
var types = path ? path.replace(/ $/, '').split(/ +/) : [];
|
|
2463
|
-
if (stack.length <= deep)
|
|
2464
|
-
return this.$.$mol_fail(new Error(`Too many tabs at ${baseUri}:${row}\n${line}`));
|
|
2465
|
-
stack.length = deep + 1;
|
|
2466
|
-
var parent = stack[deep];
|
|
2467
|
-
let col = deep;
|
|
2468
|
-
types.forEach(type => {
|
|
2469
|
-
if (!type)
|
|
2470
|
-
return this.$.$mol_fail(new Error(`Unexpected space symbol ${baseUri}:${row}\n${line}`));
|
|
2471
|
-
var next = new $mol_tree({ type, baseUri, row, col, length: type.length });
|
|
2472
|
-
const parent_sub = parent.sub;
|
|
2473
|
-
parent_sub.push(next);
|
|
2474
|
-
parent = next;
|
|
2475
|
-
col += type.length + 1;
|
|
2476
|
-
});
|
|
2477
|
-
if (data) {
|
|
2478
|
-
var next = new $mol_tree({ data: data.substring(1), baseUri, row, col, length: data.length });
|
|
2479
|
-
const parent_sub = parent.sub;
|
|
2480
|
-
parent_sub.push(next);
|
|
2481
|
-
parent = next;
|
|
2482
|
-
}
|
|
2483
|
-
stack.push(parent);
|
|
2484
|
-
});
|
|
2485
|
-
return root;
|
|
2486
|
-
}
|
|
2487
|
-
static fromJSON(json, baseUri = '') {
|
|
2488
|
-
switch (true) {
|
|
2489
|
-
case typeof json === 'boolean':
|
|
2490
|
-
case typeof json === 'number':
|
|
2491
|
-
case json === null:
|
|
2492
|
-
return new $mol_tree({
|
|
2493
|
-
type: String(json),
|
|
2494
|
-
baseUri: baseUri
|
|
2495
|
-
});
|
|
2496
|
-
case typeof json === 'string':
|
|
2497
|
-
return new $mol_tree({
|
|
2498
|
-
value: json,
|
|
2499
|
-
baseUri: baseUri
|
|
2500
|
-
});
|
|
2501
|
-
case Array.isArray(json):
|
|
2502
|
-
return new $mol_tree({
|
|
2503
|
-
type: "/",
|
|
2504
|
-
sub: json.map(json => $mol_tree.fromJSON(json, baseUri))
|
|
2505
|
-
});
|
|
2506
|
-
case json instanceof Date:
|
|
2507
|
-
return new $mol_tree({
|
|
2508
|
-
value: json.toISOString(),
|
|
2509
|
-
baseUri: baseUri
|
|
2510
|
-
});
|
|
2511
|
-
default:
|
|
2512
|
-
if (typeof json[$.$mol_tree_convert] === 'function') {
|
|
2513
|
-
return json[$.$mol_tree_convert]();
|
|
2514
|
-
}
|
|
2515
|
-
if (typeof json.toJSON === 'function') {
|
|
2516
|
-
return $mol_tree.fromJSON(json.toJSON());
|
|
2517
|
-
}
|
|
2518
|
-
if (json instanceof Error) {
|
|
2519
|
-
const { name, message, stack } = json;
|
|
2520
|
-
json = { ...json, name, message, stack };
|
|
2521
|
-
}
|
|
2522
|
-
var sub = [];
|
|
2523
|
-
for (var key in json) {
|
|
2524
|
-
if (json[key] === undefined)
|
|
2525
|
-
continue;
|
|
2526
|
-
const subsub = $mol_tree.fromJSON(json[key], baseUri);
|
|
2527
|
-
if (/^[^\n\t\\ ]+$/.test(key)) {
|
|
2528
|
-
var child = new $mol_tree({
|
|
2529
|
-
type: key,
|
|
2530
|
-
baseUri: baseUri,
|
|
2531
|
-
sub: [subsub],
|
|
2532
|
-
});
|
|
2533
|
-
}
|
|
2534
|
-
else {
|
|
2535
|
-
var child = new $mol_tree({
|
|
2536
|
-
value: key,
|
|
2537
|
-
baseUri: baseUri,
|
|
2538
|
-
sub: [subsub],
|
|
2539
|
-
});
|
|
2540
|
-
}
|
|
2541
|
-
sub.push(child);
|
|
2542
|
-
}
|
|
2543
|
-
return new $mol_tree({
|
|
2544
|
-
type: "*",
|
|
2545
|
-
sub: sub,
|
|
2546
|
-
baseUri: baseUri
|
|
2547
|
-
});
|
|
2548
|
-
}
|
|
2549
|
-
}
|
|
2550
|
-
get uri() {
|
|
2551
|
-
return this.baseUri + '#' + this.row + ':' + this.col;
|
|
2552
|
-
}
|
|
2553
|
-
toString(prefix = '') {
|
|
2554
|
-
var output = '';
|
|
2555
|
-
if (this.type.length) {
|
|
2556
|
-
if (!prefix.length) {
|
|
2557
|
-
prefix = "\t";
|
|
2558
|
-
}
|
|
2559
|
-
output += this.type;
|
|
2560
|
-
if (this.sub.length == 1) {
|
|
2561
|
-
return output + ' ' + this.sub[0].toString(prefix);
|
|
2562
|
-
}
|
|
2563
|
-
output += "\n";
|
|
2564
|
-
}
|
|
2565
|
-
else if (this.data.length || prefix.length) {
|
|
2566
|
-
output += "\\" + this.data + "\n";
|
|
2567
|
-
}
|
|
2568
|
-
for (var child of this.sub) {
|
|
2569
|
-
output += prefix;
|
|
2570
|
-
output += child.toString(prefix + "\t");
|
|
2571
|
-
}
|
|
2572
|
-
return output;
|
|
2573
|
-
}
|
|
2574
|
-
toJSON() {
|
|
2575
|
-
if (!this.type)
|
|
2576
|
-
return this.value;
|
|
2577
|
-
if (this.type === 'true')
|
|
2578
|
-
return true;
|
|
2579
|
-
if (this.type === 'false')
|
|
2580
|
-
return false;
|
|
2581
|
-
if (this.type === 'null')
|
|
2582
|
-
return null;
|
|
2583
|
-
if (this.type === '*') {
|
|
2584
|
-
var obj = {};
|
|
2585
|
-
for (var child of this.sub) {
|
|
2586
|
-
if (child.type === '-')
|
|
2587
|
-
continue;
|
|
2588
|
-
var key = child.type || child.clone({ sub: child.sub.slice(0, child.sub.length - 1) }).value;
|
|
2589
|
-
var val = child.sub[child.sub.length - 1].toJSON();
|
|
2590
|
-
if (val !== undefined)
|
|
2591
|
-
obj[key] = val;
|
|
2592
|
-
}
|
|
2593
|
-
return obj;
|
|
2594
|
-
}
|
|
2595
|
-
if (this.type === '/') {
|
|
2596
|
-
var res = [];
|
|
2597
|
-
this.sub.forEach(child => {
|
|
2598
|
-
if (child.type === '-')
|
|
2599
|
-
return;
|
|
2600
|
-
var val = child.toJSON();
|
|
2601
|
-
if (val !== undefined)
|
|
2602
|
-
res.push(val);
|
|
2603
|
-
});
|
|
2604
|
-
return res;
|
|
2605
|
-
}
|
|
2606
|
-
if (this.type === 'time') {
|
|
2607
|
-
return new Date(this.value);
|
|
2608
|
-
}
|
|
2609
|
-
const numb = Number(this.type);
|
|
2610
|
-
if (!Number.isNaN(numb) || this.type === 'NaN')
|
|
2611
|
-
return numb;
|
|
2612
|
-
throw new Error(`Unknown type (${this.type}) at ${this.uri}`);
|
|
2613
|
-
}
|
|
2614
|
-
get value() {
|
|
2615
|
-
var values = [];
|
|
2616
|
-
for (var child of this.sub) {
|
|
2617
|
-
if (child.type)
|
|
2618
|
-
continue;
|
|
2619
|
-
values.push(child.value);
|
|
2620
|
-
}
|
|
2621
|
-
return this.data + values.join("\n");
|
|
2622
|
-
}
|
|
2623
|
-
insert(value, ...path) {
|
|
2624
|
-
if (path.length === 0)
|
|
2625
|
-
return value;
|
|
2626
|
-
const type = path[0];
|
|
2627
|
-
if (typeof type === 'string') {
|
|
2628
|
-
let replaced = false;
|
|
2629
|
-
const sub = this.sub.map((item, index) => {
|
|
2630
|
-
if (item.type !== type)
|
|
2631
|
-
return item;
|
|
2632
|
-
replaced = true;
|
|
2633
|
-
return item.insert(value, ...path.slice(1));
|
|
2634
|
-
});
|
|
2635
|
-
if (!replaced)
|
|
2636
|
-
sub.push(new $mol_tree({ type }).insert(value, ...path.slice(1)));
|
|
2637
|
-
return this.clone({ sub });
|
|
2638
|
-
}
|
|
2639
|
-
else if (typeof type === 'number') {
|
|
2640
|
-
const sub = this.sub.slice();
|
|
2641
|
-
sub[type] = (sub[type] || new $mol_tree).insert(value, ...path.slice(1));
|
|
2642
|
-
return this.clone({ sub });
|
|
2643
|
-
}
|
|
2644
|
-
else {
|
|
2645
|
-
return this.clone({ sub: ((this.sub.length === 0) ? [new $mol_tree()] : this.sub).map(item => item.insert(value, ...path.slice(1))) });
|
|
2646
|
-
}
|
|
2647
|
-
}
|
|
2648
|
-
select(...path) {
|
|
2649
|
-
var next = [this];
|
|
2650
|
-
for (var type of path) {
|
|
2651
|
-
if (!next.length)
|
|
2652
|
-
break;
|
|
2653
|
-
var prev = next;
|
|
2654
|
-
next = [];
|
|
2655
|
-
for (var item of prev) {
|
|
2656
|
-
switch (typeof (type)) {
|
|
2657
|
-
case 'string':
|
|
2658
|
-
for (var child of item.sub) {
|
|
2659
|
-
if (!type || (child.type == type)) {
|
|
2660
|
-
next.push(child);
|
|
2661
|
-
}
|
|
2662
|
-
}
|
|
2663
|
-
break;
|
|
2664
|
-
case 'number':
|
|
2665
|
-
if (type < item.sub.length)
|
|
2666
|
-
next.push(item.sub[type]);
|
|
2667
|
-
break;
|
|
2668
|
-
default: next.push(...item.sub);
|
|
2669
|
-
}
|
|
2670
|
-
}
|
|
2671
|
-
}
|
|
2672
|
-
return new $mol_tree({ sub: next });
|
|
2673
|
-
}
|
|
2674
|
-
filter(path, value) {
|
|
2675
|
-
var sub = this.sub.filter(function (item) {
|
|
2676
|
-
var found = item.select(...path);
|
|
2677
|
-
if (value == null) {
|
|
2678
|
-
return Boolean(found.sub.length);
|
|
2679
|
-
}
|
|
2680
|
-
else {
|
|
2681
|
-
return found.sub.some(child => child.value == value);
|
|
2682
|
-
}
|
|
2683
|
-
});
|
|
2684
|
-
return new $mol_tree({ sub: sub });
|
|
2685
|
-
}
|
|
2686
|
-
transform(visit, stack = []) {
|
|
2687
|
-
const sub_stack = [this, ...stack];
|
|
2688
|
-
return visit(sub_stack, () => this.sub.map(node => node.transform(visit, sub_stack)).filter(n => n));
|
|
2689
|
-
}
|
|
2690
|
-
hack(context) {
|
|
2691
|
-
const sub = [].concat(...this.sub.map(child => {
|
|
2692
|
-
const handle = context[child.type] || context[''];
|
|
2693
|
-
if (!handle)
|
|
2694
|
-
$mol_fail(child.error('Handler not defined'));
|
|
2695
|
-
return handle(child, context);
|
|
2696
|
-
}));
|
|
2697
|
-
return this.clone({ sub });
|
|
2698
|
-
}
|
|
2699
|
-
error(message) {
|
|
2700
|
-
return new Error(`${message}:\n${this} ${this.baseUri}:${this.row}:${this.col}`);
|
|
2701
|
-
}
|
|
2702
|
-
}
|
|
2703
|
-
$.$mol_tree = $mol_tree;
|
|
2704
|
-
})($ || ($ = {}));
|
|
2705
|
-
//mol/tree/tree.ts
|
|
2706
|
-
;
|
|
2707
|
-
"use strict";
|
|
2708
|
-
var $;
|
|
2709
|
-
(function ($_1) {
|
|
2710
|
-
$mol_test({
|
|
2711
|
-
'tree parsing'() {
|
|
2712
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
2713
|
-
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
2714
|
-
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
2715
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
2716
|
-
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
2717
|
-
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
2718
|
-
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
2719
|
-
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
2720
|
-
},
|
|
2721
|
-
'inserting'() {
|
|
2722
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
2723
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
2724
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
2725
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
2726
|
-
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
2727
|
-
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
2728
|
-
},
|
|
2729
|
-
'fromJSON'() {
|
|
2730
|
-
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
2731
|
-
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
2732
|
-
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
2733
|
-
$mol_assert_equal($mol_tree.fromJSON(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
|
|
2734
|
-
$mol_assert_equal($mol_tree.fromJSON({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
|
|
2735
|
-
},
|
|
2736
|
-
'toJSON'() {
|
|
2737
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
2738
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
2739
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
2740
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n').sub[0]), '["","foo","bar\\nbaz"]');
|
|
2741
|
-
$mol_assert_equal(JSON.stringify($mol_tree.fromString('*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n').sub[0]), '{"foo":false,"bar\\nbaz":"lol"}');
|
|
2742
|
-
},
|
|
2743
|
-
'hack'() {
|
|
2744
|
-
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
2745
|
-
'': (tree, context) => [tree.hack(context)],
|
|
2746
|
-
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
2747
|
-
});
|
|
2748
|
-
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
2749
|
-
},
|
|
2750
|
-
'errors handling'($) {
|
|
2751
|
-
const errors = [];
|
|
2752
|
-
class Tree extends $mol_tree {
|
|
2753
|
-
static $ = $.$mol_ambient({
|
|
2754
|
-
$mol_fail: error => errors.push(error.message)
|
|
2755
|
-
});
|
|
2756
|
-
}
|
|
2757
|
-
Tree.fromString(`
|
|
2758
|
-
\t \tfoo
|
|
2759
|
-
bar \\data
|
|
2760
|
-
`, 'test');
|
|
2761
|
-
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
2762
|
-
},
|
|
2763
|
-
});
|
|
2764
|
-
})($ || ($ = {}));
|
|
2765
|
-
//mol/tree/tree.test.ts
|
|
2766
|
-
;
|
|
2767
|
-
"use strict";
|
|
2768
|
-
var $;
|
|
2769
2384
|
(function ($_1) {
|
|
2770
2385
|
$mol_test({
|
|
2771
2386
|
'span for same uri'($) {
|
|
@@ -2818,6 +2433,65 @@ var $;
|
|
|
2818
2433
|
;
|
|
2819
2434
|
"use strict";
|
|
2820
2435
|
var $;
|
|
2436
|
+
(function ($) {
|
|
2437
|
+
$mol_test({
|
|
2438
|
+
'fromJSON'() {
|
|
2439
|
+
$mol_assert_equal($mol_tree2_from_json([]).toString(), '/\n');
|
|
2440
|
+
$mol_assert_equal($mol_tree2_from_json([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
2441
|
+
$mol_assert_equal($mol_tree2_from_json([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
2442
|
+
$mol_assert_equal($mol_tree2_from_json(new Uint16Array([1, 10, 256])).toString(), '\\\x01\x00\n\\\x00\x00\x01\n');
|
|
2443
|
+
$mol_assert_equal($mol_tree2_from_json(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
|
|
2444
|
+
$mol_assert_equal($mol_tree2_from_json({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
|
|
2445
|
+
},
|
|
2446
|
+
});
|
|
2447
|
+
})($ || ($ = {}));
|
|
2448
|
+
//mol/tree2/from/json/json.test.ts
|
|
2449
|
+
;
|
|
2450
|
+
"use strict";
|
|
2451
|
+
var $;
|
|
2452
|
+
(function ($_1) {
|
|
2453
|
+
$mol_test({
|
|
2454
|
+
'inserting'($) {
|
|
2455
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
|
2456
|
+
.insert($mol_tree2.struct('x'), 'a', 'b', 'c')
|
|
2457
|
+
.toString(), 'a b x\n');
|
|
2458
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b\n')
|
|
2459
|
+
.insert($mol_tree2.struct('x'), 'a', 'b', 'c', 'd')
|
|
2460
|
+
.toString(), 'a b c x\n');
|
|
2461
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
|
2462
|
+
.insert($mol_tree2.struct('x'), 0, 0, 0)
|
|
2463
|
+
.toString(), 'a b x\n');
|
|
2464
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b\n')
|
|
2465
|
+
.insert($mol_tree2.struct('x'), 0, 0, 0, 0)
|
|
2466
|
+
.toString(), 'a b \\\n\tx\n');
|
|
2467
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
|
2468
|
+
.insert($mol_tree2.struct('x'), null, null, null)
|
|
2469
|
+
.toString(), 'a b x\n');
|
|
2470
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b\n')
|
|
2471
|
+
.insert($mol_tree2.struct('x'), null, null, null, null)
|
|
2472
|
+
.toString(), 'a b \\\n\tx\n');
|
|
2473
|
+
},
|
|
2474
|
+
'deleting'($) {
|
|
2475
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
|
2476
|
+
.insert(null, 'a', 'b', 'c')
|
|
2477
|
+
.toString(), 'a b\n');
|
|
2478
|
+
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
|
2479
|
+
.insert(null, 0, 0, 0)
|
|
2480
|
+
.toString(), 'a b\n');
|
|
2481
|
+
},
|
|
2482
|
+
'hack'($) {
|
|
2483
|
+
const res = $.$mol_tree2_from_string(`foo bar xxx\n`)
|
|
2484
|
+
.hack({
|
|
2485
|
+
'bar': (input, belt) => [input.struct('777', input.hack(belt))],
|
|
2486
|
+
});
|
|
2487
|
+
$mol_assert_equal(res.toString(), 'foo 777 xxx\n');
|
|
2488
|
+
},
|
|
2489
|
+
});
|
|
2490
|
+
})($ || ($ = {}));
|
|
2491
|
+
//mol/tree2/tree2.test.ts
|
|
2492
|
+
;
|
|
2493
|
+
"use strict";
|
|
2494
|
+
var $;
|
|
2821
2495
|
(function ($_1) {
|
|
2822
2496
|
$mol_test({
|
|
2823
2497
|
'tree parsing'($) {
|
|
@@ -2881,64 +2555,6 @@ var $;
|
|
|
2881
2555
|
//mol/tree2/from/string/string.test.ts
|
|
2882
2556
|
;
|
|
2883
2557
|
"use strict";
|
|
2884
|
-
var $;
|
|
2885
|
-
(function ($_1) {
|
|
2886
|
-
$mol_test({
|
|
2887
|
-
'inserting'($) {
|
|
2888
|
-
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
|
2889
|
-
.insert($mol_tree2.struct('x'), 'a', 'b', 'c')
|
|
2890
|
-
.toString(), 'a b x\n');
|
|
2891
|
-
$mol_assert_equal($.$mol_tree2_from_string('a b\n')
|
|
2892
|
-
.insert($mol_tree2.struct('x'), 'a', 'b', 'c', 'd')
|
|
2893
|
-
.toString(), 'a b c x\n');
|
|
2894
|
-
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
|
2895
|
-
.insert($mol_tree2.struct('x'), 0, 0, 0)
|
|
2896
|
-
.toString(), 'a b x\n');
|
|
2897
|
-
$mol_assert_equal($.$mol_tree2_from_string('a b\n')
|
|
2898
|
-
.insert($mol_tree2.struct('x'), 0, 0, 0, 0)
|
|
2899
|
-
.toString(), 'a b \\\n\tx\n');
|
|
2900
|
-
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
|
2901
|
-
.insert($mol_tree2.struct('x'), null, null, null)
|
|
2902
|
-
.toString(), 'a b x\n');
|
|
2903
|
-
$mol_assert_equal($.$mol_tree2_from_string('a b\n')
|
|
2904
|
-
.insert($mol_tree2.struct('x'), null, null, null, null)
|
|
2905
|
-
.toString(), 'a b \\\n\tx\n');
|
|
2906
|
-
},
|
|
2907
|
-
'deleting'($) {
|
|
2908
|
-
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
|
2909
|
-
.insert(null, 'a', 'b', 'c')
|
|
2910
|
-
.toString(), 'a b\n');
|
|
2911
|
-
$mol_assert_equal($.$mol_tree2_from_string('a b c d\n')
|
|
2912
|
-
.insert(null, 0, 0, 0)
|
|
2913
|
-
.toString(), 'a b\n');
|
|
2914
|
-
},
|
|
2915
|
-
'hack'($) {
|
|
2916
|
-
const res = $.$mol_tree2_from_string(`foo bar xxx\n`)
|
|
2917
|
-
.hack({
|
|
2918
|
-
'bar': (input, belt) => [input.struct('777', input.hack(belt))],
|
|
2919
|
-
});
|
|
2920
|
-
$mol_assert_equal(res.toString(), 'foo 777 xxx\n');
|
|
2921
|
-
},
|
|
2922
|
-
});
|
|
2923
|
-
})($ || ($ = {}));
|
|
2924
|
-
//mol/tree2/tree2.test.ts
|
|
2925
|
-
;
|
|
2926
|
-
"use strict";
|
|
2927
|
-
var $;
|
|
2928
|
-
(function ($) {
|
|
2929
|
-
$mol_test({
|
|
2930
|
-
'fromJSON'() {
|
|
2931
|
-
$mol_assert_equal($mol_tree2_from_json([]).toString(), '/\n');
|
|
2932
|
-
$mol_assert_equal($mol_tree2_from_json([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
2933
|
-
$mol_assert_equal($mol_tree2_from_json([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
2934
|
-
$mol_assert_equal($mol_tree2_from_json(['', 'foo', 'bar\nbaz']).toString(), '/\n\t\\\n\t\\foo\n\t\\\n\t\t\\bar\n\t\t\\baz\n');
|
|
2935
|
-
$mol_assert_equal($mol_tree2_from_json({ 'foo': false, 'bar\nbaz': 'lol' }).toString(), '*\n\tfoo false\n\t\\\n\t\t\\bar\n\t\t\\baz\n\t\t\\lol\n');
|
|
2936
|
-
},
|
|
2937
|
-
});
|
|
2938
|
-
})($ || ($ = {}));
|
|
2939
|
-
//mol/tree2/from/json/json.test.ts
|
|
2940
|
-
;
|
|
2941
|
-
"use strict";
|
|
2942
2558
|
//mol/type/unary/unary.ts
|
|
2943
2559
|
;
|
|
2944
2560
|
"use strict";
|