mol_mutable 0.0.1218 → 0.0.1220
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 +6 -0
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +1 -0
- package/node.js.map +1 -1
- package/node.mjs +1 -0
- package/node.test.js +247 -9
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +6 -0
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +1 -0
- package/web.js.map +1 -1
- package/web.mjs +1 -0
- package/web.test.js +67 -1
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -26,6 +26,7 @@ $.$$ = $
|
|
|
26
26
|
"use strict";
|
|
27
27
|
var $;
|
|
28
28
|
(function ($) {
|
|
29
|
+
/** Mutable way for immutable patch */
|
|
29
30
|
function $mol_mutable(input, update = next => input = next) {
|
|
30
31
|
let output = undefined;
|
|
31
32
|
const clone = Array.isArray(input)
|
|
@@ -92,7 +93,7 @@ var $;
|
|
|
92
93
|
var $;
|
|
93
94
|
(function ($) {
|
|
94
95
|
function $mol_fail_hidden(error) {
|
|
95
|
-
throw error;
|
|
96
|
+
throw error; /// Use 'Never Pause Here' breakpoint in DevTools or simply blackbox this script
|
|
96
97
|
}
|
|
97
98
|
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
98
99
|
})($ || ($ = {}));
|
|
@@ -207,7 +208,7 @@ var $;
|
|
|
207
208
|
"use strict";
|
|
208
209
|
var $;
|
|
209
210
|
(function ($) {
|
|
210
|
-
const mod = require('module');
|
|
211
|
+
const mod = require /****/('module');
|
|
211
212
|
const internals = mod.builtinModules;
|
|
212
213
|
function $node_internal_check(name) {
|
|
213
214
|
if (name.startsWith('node:'))
|
|
@@ -221,8 +222,8 @@ var $;
|
|
|
221
222
|
"use strict";
|
|
222
223
|
var $;
|
|
223
224
|
(function ($) {
|
|
224
|
-
const path = require('path');
|
|
225
|
-
const mod = require('module');
|
|
225
|
+
const path = require /****/('path');
|
|
226
|
+
const mod = require /****/('module');
|
|
226
227
|
const localRequire = mod.createRequire(path.join(process.cwd(), 'package.json'));
|
|
227
228
|
function $node_autoinstall(name) {
|
|
228
229
|
try {
|
|
@@ -343,6 +344,7 @@ var $;
|
|
|
343
344
|
])
|
|
344
345
|
].map(frame_normalize).join('\n')
|
|
345
346
|
});
|
|
347
|
+
// в nodejs, что б не дублировалось cause в консоли
|
|
346
348
|
Object.defineProperty(this, 'cause', {
|
|
347
349
|
get: () => cause
|
|
348
350
|
});
|
|
@@ -518,6 +520,9 @@ var $;
|
|
|
518
520
|
[Symbol.dispose]() {
|
|
519
521
|
this.destructor();
|
|
520
522
|
}
|
|
523
|
+
//[ Symbol.toPrimitive ]( hint: string ) {
|
|
524
|
+
// return hint === 'number' ? this.valueOf() : this.toString()
|
|
525
|
+
//}
|
|
521
526
|
toString() {
|
|
522
527
|
return this[Symbol.toStringTag] || this.constructor.name + '<>';
|
|
523
528
|
}
|
|
@@ -594,6 +599,7 @@ var $;
|
|
|
594
599
|
"use strict";
|
|
595
600
|
var $;
|
|
596
601
|
(function ($) {
|
|
602
|
+
/** Generates unique identifier. */
|
|
597
603
|
function $mol_guid(length = 8, exists = () => false) {
|
|
598
604
|
for (;;) {
|
|
599
605
|
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
@@ -609,11 +615,16 @@ var $;
|
|
|
609
615
|
"use strict";
|
|
610
616
|
var $;
|
|
611
617
|
(function ($) {
|
|
618
|
+
/** Special status statuses. */
|
|
612
619
|
let $mol_wire_cursor;
|
|
613
620
|
(function ($mol_wire_cursor) {
|
|
621
|
+
/** Update required. */
|
|
614
622
|
$mol_wire_cursor[$mol_wire_cursor["stale"] = -1] = "stale";
|
|
623
|
+
/** Some of (transitive) pub update required. */
|
|
615
624
|
$mol_wire_cursor[$mol_wire_cursor["doubt"] = -2] = "doubt";
|
|
625
|
+
/** Actual state but may be dropped. */
|
|
616
626
|
$mol_wire_cursor[$mol_wire_cursor["fresh"] = -3] = "fresh";
|
|
627
|
+
/** State will never be changed. */
|
|
617
628
|
$mol_wire_cursor[$mol_wire_cursor["final"] = -4] = "final";
|
|
618
629
|
})($mol_wire_cursor = $.$mol_wire_cursor || ($.$mol_wire_cursor = {}));
|
|
619
630
|
})($ || ($ = {}));
|
|
@@ -622,6 +633,9 @@ var $;
|
|
|
622
633
|
"use strict";
|
|
623
634
|
var $;
|
|
624
635
|
(function ($) {
|
|
636
|
+
/**
|
|
637
|
+
* Collects subscribers in compact array. 28B
|
|
638
|
+
*/
|
|
625
639
|
class $mol_wire_pub extends Object {
|
|
626
640
|
constructor(id = `$mol_wire_pub:${$mol_guid()}`) {
|
|
627
641
|
super();
|
|
@@ -629,10 +643,17 @@ var $;
|
|
|
629
643
|
}
|
|
630
644
|
[Symbol.toStringTag];
|
|
631
645
|
data = [];
|
|
646
|
+
// Derived objects should be Arrays.
|
|
632
647
|
static get [Symbol.species]() {
|
|
633
648
|
return Array;
|
|
634
649
|
}
|
|
635
|
-
|
|
650
|
+
/**
|
|
651
|
+
* Index of first subscriber.
|
|
652
|
+
*/
|
|
653
|
+
sub_from = 0; // 4B
|
|
654
|
+
/**
|
|
655
|
+
* All current subscribers.
|
|
656
|
+
*/
|
|
636
657
|
get sub_list() {
|
|
637
658
|
const res = [];
|
|
638
659
|
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
@@ -640,14 +661,23 @@ var $;
|
|
|
640
661
|
}
|
|
641
662
|
return res;
|
|
642
663
|
}
|
|
664
|
+
/**
|
|
665
|
+
* Has any subscribers or not.
|
|
666
|
+
*/
|
|
643
667
|
get sub_empty() {
|
|
644
668
|
return this.sub_from === this.data.length;
|
|
645
669
|
}
|
|
670
|
+
/**
|
|
671
|
+
* Subscribe subscriber to this publisher events and return position of subscriber that required to unsubscribe.
|
|
672
|
+
*/
|
|
646
673
|
sub_on(sub, pub_pos) {
|
|
647
674
|
const pos = this.data.length;
|
|
648
675
|
this.data.push(sub, pub_pos);
|
|
649
676
|
return pos;
|
|
650
677
|
}
|
|
678
|
+
/**
|
|
679
|
+
* Unsubscribe subscriber from this publisher events by subscriber position provided by `on(pub)`.
|
|
680
|
+
*/
|
|
651
681
|
sub_off(sub_pos) {
|
|
652
682
|
if (!(sub_pos < this.data.length)) {
|
|
653
683
|
$mol_fail(new Error(`Wrong pos ${sub_pos}`));
|
|
@@ -660,21 +690,39 @@ var $;
|
|
|
660
690
|
if (end === this.sub_from)
|
|
661
691
|
this.reap();
|
|
662
692
|
}
|
|
693
|
+
/**
|
|
694
|
+
* Called when last sub was unsubscribed.
|
|
695
|
+
**/
|
|
663
696
|
reap() { }
|
|
697
|
+
/**
|
|
698
|
+
* Autowire this publisher with current subscriber.
|
|
699
|
+
**/
|
|
664
700
|
promote() {
|
|
665
701
|
$mol_wire_auto()?.track_next(this);
|
|
666
702
|
}
|
|
703
|
+
/**
|
|
704
|
+
* Enforce actualization. Should not throw errors.
|
|
705
|
+
*/
|
|
667
706
|
fresh() { }
|
|
707
|
+
/**
|
|
708
|
+
* Allow to put data to caches in the subtree.
|
|
709
|
+
*/
|
|
668
710
|
complete() { }
|
|
669
711
|
get incompleted() {
|
|
670
712
|
return false;
|
|
671
713
|
}
|
|
714
|
+
/**
|
|
715
|
+
* Notify subscribers about self changes.
|
|
716
|
+
*/
|
|
672
717
|
emit(quant = $mol_wire_cursor.stale) {
|
|
673
718
|
for (let i = this.sub_from; i < this.data.length; i += 2) {
|
|
674
719
|
;
|
|
675
720
|
this.data[i].absorb(quant, this.data[i + 1]);
|
|
676
721
|
}
|
|
677
722
|
}
|
|
723
|
+
/**
|
|
724
|
+
* Moves peer from one position to another. Doesn't clear data at old position!
|
|
725
|
+
*/
|
|
678
726
|
peer_move(from_pos, to_pos) {
|
|
679
727
|
const peer = this.data[from_pos];
|
|
680
728
|
const self_pos = this.data[from_pos + 1];
|
|
@@ -682,6 +730,9 @@ var $;
|
|
|
682
730
|
this.data[to_pos + 1] = self_pos;
|
|
683
731
|
peer.peer_repos(self_pos, to_pos);
|
|
684
732
|
}
|
|
733
|
+
/**
|
|
734
|
+
* Updates self position in the peer.
|
|
735
|
+
*/
|
|
685
736
|
peer_repos(peer_pos, self_pos) {
|
|
686
737
|
this.data[peer_pos + 1] = self_pos;
|
|
687
738
|
}
|
|
@@ -697,10 +748,16 @@ var $;
|
|
|
697
748
|
var $;
|
|
698
749
|
(function ($) {
|
|
699
750
|
$.$mol_wire_auto_sub = null;
|
|
751
|
+
/**
|
|
752
|
+
* When fulfilled, all publishers are promoted to this subscriber on access to its.
|
|
753
|
+
*/
|
|
700
754
|
function $mol_wire_auto(next = $.$mol_wire_auto_sub) {
|
|
701
755
|
return $.$mol_wire_auto_sub = next;
|
|
702
756
|
}
|
|
703
757
|
$.$mol_wire_auto = $mol_wire_auto;
|
|
758
|
+
/**
|
|
759
|
+
* Affection queue. Used to prevent accidental stack overflow on emit.
|
|
760
|
+
*/
|
|
704
761
|
$.$mol_wire_affected = [];
|
|
705
762
|
})($ || ($ = {}));
|
|
706
763
|
|
|
@@ -708,6 +765,7 @@ var $;
|
|
|
708
765
|
"use strict";
|
|
709
766
|
var $;
|
|
710
767
|
(function ($) {
|
|
768
|
+
// https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview#
|
|
711
769
|
$['devtoolsFormatters'] ||= [];
|
|
712
770
|
function $mol_dev_format_register(config) {
|
|
713
771
|
$['devtoolsFormatters'].push(config);
|
|
@@ -759,6 +817,7 @@ var $;
|
|
|
759
817
|
return false;
|
|
760
818
|
if (!val)
|
|
761
819
|
return false;
|
|
820
|
+
// if( Error.isError( val ) ) true
|
|
762
821
|
if (val[$.$mol_dev_format_body])
|
|
763
822
|
return true;
|
|
764
823
|
return false;
|
|
@@ -776,12 +835,16 @@ var $;
|
|
|
776
835
|
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
777
836
|
}
|
|
778
837
|
}
|
|
838
|
+
// if( Error.isError( val ) ) {
|
|
839
|
+
// return $mol_dev_format_native( val )
|
|
840
|
+
// }
|
|
779
841
|
return null;
|
|
780
842
|
},
|
|
781
843
|
});
|
|
782
844
|
function $mol_dev_format_native(obj) {
|
|
783
845
|
if (typeof obj === 'undefined')
|
|
784
846
|
return $.$mol_dev_format_shade('undefined');
|
|
847
|
+
// if( ![ 'object', 'function', 'symbol' ].includes( typeof obj ) ) return obj
|
|
785
848
|
return [
|
|
786
849
|
'object',
|
|
787
850
|
{
|
|
@@ -839,6 +902,9 @@ var $;
|
|
|
839
902
|
'margin-left': '13px'
|
|
840
903
|
});
|
|
841
904
|
class Stack extends Array {
|
|
905
|
+
// [ Symbol.toPrimitive ]() {
|
|
906
|
+
// return this.toString()
|
|
907
|
+
// }
|
|
842
908
|
toString() {
|
|
843
909
|
return this.join('\n');
|
|
844
910
|
}
|
|
@@ -861,6 +927,7 @@ var $;
|
|
|
861
927
|
this.method = call.getMethodName() ?? '';
|
|
862
928
|
if (this.method === this.function)
|
|
863
929
|
this.method = '';
|
|
930
|
+
// const func = c.getFunction()
|
|
864
931
|
this.pos = [call.getEnclosingLineNumber() ?? 0, call.getEnclosingColumnNumber() ?? 0];
|
|
865
932
|
this.eval = call.getEvalOrigin() ?? '';
|
|
866
933
|
this.source = call.getScriptNameOrSourceURL() ?? '';
|
|
@@ -907,9 +974,16 @@ var $;
|
|
|
907
974
|
"use strict";
|
|
908
975
|
var $;
|
|
909
976
|
(function ($) {
|
|
977
|
+
/**
|
|
978
|
+
* Publisher that can auto collect other publishers. 32B
|
|
979
|
+
*
|
|
980
|
+
* P1 P2 P3 P4 S1 S2 S3
|
|
981
|
+
* ^ ^
|
|
982
|
+
* pubs_from subs_from
|
|
983
|
+
*/
|
|
910
984
|
class $mol_wire_pub_sub extends $mol_wire_pub {
|
|
911
|
-
pub_from = 0;
|
|
912
|
-
cursor = $mol_wire_cursor.stale;
|
|
985
|
+
pub_from = 0; // 4B
|
|
986
|
+
cursor = $mol_wire_cursor.stale; // 4B
|
|
913
987
|
get temp() {
|
|
914
988
|
return false;
|
|
915
989
|
}
|
|
@@ -1027,10 +1101,27 @@ var $;
|
|
|
1027
1101
|
return;
|
|
1028
1102
|
this.cursor = quant;
|
|
1029
1103
|
this.emit($mol_wire_cursor.doubt);
|
|
1104
|
+
// if( pos >= 0 && pos < this.sub_from - 2 ) {
|
|
1105
|
+
// const pub = this.data[ pos ] as $mol_wire_pub
|
|
1106
|
+
// if( pub instanceof $mol_wire_task ) return
|
|
1107
|
+
// for(
|
|
1108
|
+
// let cursor = this.pub_from;
|
|
1109
|
+
// cursor < this.sub_from;
|
|
1110
|
+
// cursor += 2
|
|
1111
|
+
// ) {
|
|
1112
|
+
// const pub = this.data[ cursor ] as $mol_wire_pub
|
|
1113
|
+
// if( pub instanceof $mol_wire_task ) {
|
|
1114
|
+
// pub.destructor()
|
|
1115
|
+
// }
|
|
1116
|
+
// }
|
|
1117
|
+
// }
|
|
1030
1118
|
}
|
|
1031
1119
|
[$mol_dev_format_head]() {
|
|
1032
1120
|
return $mol_dev_format_native(this);
|
|
1033
1121
|
}
|
|
1122
|
+
/**
|
|
1123
|
+
* Is subscribed to any publisher or not.
|
|
1124
|
+
*/
|
|
1034
1125
|
get pub_empty() {
|
|
1035
1126
|
return this.sub_from === this.pub_from;
|
|
1036
1127
|
}
|
|
@@ -1100,6 +1191,7 @@ var $;
|
|
|
1100
1191
|
"use strict";
|
|
1101
1192
|
var $;
|
|
1102
1193
|
(function ($) {
|
|
1194
|
+
/// @todo right orderinng
|
|
1103
1195
|
$.$mol_after_mock_queue = [];
|
|
1104
1196
|
function $mol_after_mock_warp() {
|
|
1105
1197
|
const queue = $.$mol_after_mock_queue.splice(0);
|
|
@@ -1176,6 +1268,13 @@ var $;
|
|
|
1176
1268
|
var $;
|
|
1177
1269
|
(function ($) {
|
|
1178
1270
|
const wrappers = new WeakMap();
|
|
1271
|
+
/**
|
|
1272
|
+
* Suspendable task with support both sync/async api.
|
|
1273
|
+
*
|
|
1274
|
+
* A1 A2 A3 A4 P1 P2 P3 P4 S1 S2 S3
|
|
1275
|
+
* ^ ^ ^
|
|
1276
|
+
* args_from pubs_from subs_from
|
|
1277
|
+
**/
|
|
1179
1278
|
class $mol_wire_fiber extends $mol_wire_pub_sub {
|
|
1180
1279
|
task;
|
|
1181
1280
|
host;
|
|
@@ -1196,6 +1295,7 @@ var $;
|
|
|
1196
1295
|
});
|
|
1197
1296
|
}
|
|
1198
1297
|
static sync() {
|
|
1298
|
+
// Sync whole fiber graph
|
|
1199
1299
|
while (this.planning.size) {
|
|
1200
1300
|
for (const fiber of this.planning) {
|
|
1201
1301
|
this.planning.delete(fiber);
|
|
@@ -1206,6 +1306,7 @@ var $;
|
|
|
1206
1306
|
fiber.fresh();
|
|
1207
1307
|
}
|
|
1208
1308
|
}
|
|
1309
|
+
// Collect garbage
|
|
1209
1310
|
while (this.reaping.size) {
|
|
1210
1311
|
const fibers = this.reaping;
|
|
1211
1312
|
this.reaping = new Set;
|
|
@@ -1357,6 +1458,10 @@ var $;
|
|
|
1357
1458
|
this.cursor = $mol_wire_cursor.stale;
|
|
1358
1459
|
this.fresh();
|
|
1359
1460
|
}
|
|
1461
|
+
/**
|
|
1462
|
+
* Synchronous execution. Throws Promise when waits async task (SuspenseAPI provider).
|
|
1463
|
+
* Should be called inside SuspenseAPI consumer (ie fiber).
|
|
1464
|
+
*/
|
|
1360
1465
|
sync() {
|
|
1361
1466
|
if (!$mol_wire_fiber.warm) {
|
|
1362
1467
|
return this.result();
|
|
@@ -1371,6 +1476,10 @@ var $;
|
|
|
1371
1476
|
}
|
|
1372
1477
|
return this.cache;
|
|
1373
1478
|
}
|
|
1479
|
+
/**
|
|
1480
|
+
* Asynchronous execution.
|
|
1481
|
+
* It's SuspenseAPI consumer. So SuspenseAPI providers can be called inside.
|
|
1482
|
+
*/
|
|
1374
1483
|
async async_raw() {
|
|
1375
1484
|
while (true) {
|
|
1376
1485
|
this.fresh();
|
|
@@ -1383,6 +1492,7 @@ var $;
|
|
|
1383
1492
|
if (!$mol_promise_like(this.cache))
|
|
1384
1493
|
return this.cache;
|
|
1385
1494
|
if (this.cursor === $mol_wire_cursor.final) {
|
|
1495
|
+
// never ends on destructed fiber
|
|
1386
1496
|
await new Promise(() => { });
|
|
1387
1497
|
}
|
|
1388
1498
|
}
|
|
@@ -1511,6 +1621,7 @@ var $;
|
|
|
1511
1621
|
"use strict";
|
|
1512
1622
|
var $;
|
|
1513
1623
|
(function ($) {
|
|
1624
|
+
/** Log begin of collapsed group only when some logged inside, returns func to close group */
|
|
1514
1625
|
function $mol_log3_area_lazy(event) {
|
|
1515
1626
|
const self = this.$;
|
|
1516
1627
|
const stack = self.$mol_log3_stack;
|
|
@@ -1535,6 +1646,7 @@ var $;
|
|
|
1535
1646
|
"use strict";
|
|
1536
1647
|
var $;
|
|
1537
1648
|
(function ($) {
|
|
1649
|
+
/** Module for working with terminal. Text coloring when output in terminal */
|
|
1538
1650
|
class $mol_term_color {
|
|
1539
1651
|
static reset = this.ansi(0, 0);
|
|
1540
1652
|
static bold = this.ansi(1, 22);
|
|
@@ -1620,6 +1732,7 @@ var $;
|
|
|
1620
1732
|
"use strict";
|
|
1621
1733
|
var $;
|
|
1622
1734
|
(function ($) {
|
|
1735
|
+
/** One-shot fiber */
|
|
1623
1736
|
class $mol_wire_task extends $mol_wire_fiber {
|
|
1624
1737
|
static getter(task) {
|
|
1625
1738
|
return function $mol_wire_task_get(host, args) {
|
|
@@ -1645,6 +1758,7 @@ var $;
|
|
|
1645
1758
|
}
|
|
1646
1759
|
const key = (host?.[Symbol.toStringTag] ?? host) + ('.' + task.name + '<#>');
|
|
1647
1760
|
const next = new $mol_wire_task(key, task, host, args);
|
|
1761
|
+
// Disabled because non-idempotency is required for try-catch
|
|
1648
1762
|
if (existen?.temp) {
|
|
1649
1763
|
$$.$mol_log3_warn({
|
|
1650
1764
|
place: '$mol_wire_task',
|
|
@@ -1677,7 +1791,7 @@ var $;
|
|
|
1677
1791
|
try {
|
|
1678
1792
|
next[Symbol.toStringTag] = this[Symbol.toStringTag];
|
|
1679
1793
|
}
|
|
1680
|
-
catch {
|
|
1794
|
+
catch { // Promises throw in strict mode
|
|
1681
1795
|
Object.defineProperty(next, Symbol.toStringTag, { value: this[Symbol.toStringTag] });
|
|
1682
1796
|
}
|
|
1683
1797
|
}
|
|
@@ -1702,6 +1816,9 @@ var $;
|
|
|
1702
1816
|
"use strict";
|
|
1703
1817
|
var $;
|
|
1704
1818
|
(function ($) {
|
|
1819
|
+
/**
|
|
1820
|
+
* Decorates method to fiber to ensure it is executed only once inside other fiber.
|
|
1821
|
+
*/
|
|
1705
1822
|
function $mol_wire_method(host, field, descr) {
|
|
1706
1823
|
if (!descr)
|
|
1707
1824
|
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
@@ -1728,6 +1845,7 @@ var $;
|
|
|
1728
1845
|
"use strict";
|
|
1729
1846
|
var $;
|
|
1730
1847
|
(function ($) {
|
|
1848
|
+
/** Convert a pseudo-synchronous (Suspense API) API to an explicit asynchronous one (for integrating with external systems). */
|
|
1731
1849
|
function $mol_wire_async(obj) {
|
|
1732
1850
|
let fiber;
|
|
1733
1851
|
const temp = $mol_wire_task.getter(obj);
|
|
@@ -1839,6 +1957,10 @@ var $;
|
|
|
1839
1957
|
props[field] = get_val;
|
|
1840
1958
|
return get_val;
|
|
1841
1959
|
}
|
|
1960
|
+
/**
|
|
1961
|
+
* Convert asynchronous (promise-based) API to synchronous by wrapping function and method calls in a fiber.
|
|
1962
|
+
* @see https://mol.hyoo.ru/#!section=docs/=1fcpsq_1wh0h2
|
|
1963
|
+
*/
|
|
1842
1964
|
function $mol_wire_sync(obj) {
|
|
1843
1965
|
return new Proxy(obj, {
|
|
1844
1966
|
get(obj, field) {
|
|
@@ -2340,6 +2462,12 @@ var $;
|
|
|
2340
2462
|
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
2341
2463
|
};
|
|
2342
2464
|
$.$mol_jsx_frag = '';
|
|
2465
|
+
/**
|
|
2466
|
+
* JSX adapter that makes DOM tree.
|
|
2467
|
+
* Generates global unique ids for every DOM-element by components tree with ids.
|
|
2468
|
+
* Ensures all local ids are unique.
|
|
2469
|
+
* Can reuse an existing nodes by GUIDs when used inside [`mol_jsx_attach`](https://github.com/hyoo-ru/mam_mol/tree/master/jsx/attach).
|
|
2470
|
+
*/
|
|
2343
2471
|
function $mol_jsx(Elem, props, ...childNodes) {
|
|
2344
2472
|
const id = props && props.id || '';
|
|
2345
2473
|
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
|
@@ -2450,6 +2578,8 @@ var $;
|
|
|
2450
2578
|
|
|
2451
2579
|
;
|
|
2452
2580
|
"use strict";
|
|
2581
|
+
/** @jsx $mol_jsx */
|
|
2582
|
+
/** @jsxFrag $mol_jsx_frag */
|
|
2453
2583
|
var $;
|
|
2454
2584
|
(function ($) {
|
|
2455
2585
|
$mol_test({
|
|
@@ -2555,6 +2685,7 @@ var $;
|
|
|
2555
2685
|
"use strict";
|
|
2556
2686
|
var $;
|
|
2557
2687
|
(function ($) {
|
|
2688
|
+
/** Lazy computed lists with native Array interface. $mol_range2_array is mutable but all derived ranges are immutable. */
|
|
2558
2689
|
function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
|
|
2559
2690
|
const source = typeof item === 'function' ? new $mol_range2_array() : item;
|
|
2560
2691
|
if (typeof item !== 'function') {
|
|
@@ -2603,6 +2734,7 @@ var $;
|
|
|
2603
2734
|
}
|
|
2604
2735
|
$.$mol_range2 = $mol_range2;
|
|
2605
2736
|
class $mol_range2_array extends Array {
|
|
2737
|
+
// Lazy
|
|
2606
2738
|
concat(...tail) {
|
|
2607
2739
|
if (tail.length === 0)
|
|
2608
2740
|
return this;
|
|
@@ -2614,6 +2746,7 @@ var $;
|
|
|
2614
2746
|
}
|
|
2615
2747
|
return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
|
|
2616
2748
|
}
|
|
2749
|
+
// Lazy
|
|
2617
2750
|
filter(check, context) {
|
|
2618
2751
|
const filtered = [];
|
|
2619
2752
|
let cursor = -1;
|
|
@@ -2626,13 +2759,16 @@ var $;
|
|
|
2626
2759
|
return filtered[index];
|
|
2627
2760
|
}, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
|
|
2628
2761
|
}
|
|
2762
|
+
// Diligent
|
|
2629
2763
|
forEach(proceed, context) {
|
|
2630
2764
|
for (let [key, value] of this.entries())
|
|
2631
2765
|
proceed.call(context, value, key, this);
|
|
2632
2766
|
}
|
|
2767
|
+
// Lazy
|
|
2633
2768
|
map(proceed, context) {
|
|
2634
2769
|
return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
|
|
2635
2770
|
}
|
|
2771
|
+
// Diligent
|
|
2636
2772
|
reduce(merge, result) {
|
|
2637
2773
|
let index = 0;
|
|
2638
2774
|
if (arguments.length === 1) {
|
|
@@ -2643,12 +2779,15 @@ var $;
|
|
|
2643
2779
|
}
|
|
2644
2780
|
return result;
|
|
2645
2781
|
}
|
|
2782
|
+
// Lazy
|
|
2646
2783
|
toReversed() {
|
|
2647
2784
|
return $mol_range2(index => this[this.length - 1 - index], () => this.length);
|
|
2648
2785
|
}
|
|
2786
|
+
// Lazy
|
|
2649
2787
|
slice(from = 0, to = this.length) {
|
|
2650
2788
|
return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
|
|
2651
2789
|
}
|
|
2790
|
+
// Lazy
|
|
2652
2791
|
some(check, context) {
|
|
2653
2792
|
for (let index = 0; index < this.length; ++index) {
|
|
2654
2793
|
if (check.call(context, this[index], index, this))
|
|
@@ -2844,6 +2983,10 @@ var $;
|
|
|
2844
2983
|
var $;
|
|
2845
2984
|
(function ($) {
|
|
2846
2985
|
$.$mol_compare_deep_cache = new WeakMap();
|
|
2986
|
+
/**
|
|
2987
|
+
* Deeply compares two values. Returns true if equal.
|
|
2988
|
+
* Define `Symbol.toPrimitive` to customize.
|
|
2989
|
+
*/
|
|
2847
2990
|
function $mol_compare_deep(left, right) {
|
|
2848
2991
|
if (Object.is(left, right))
|
|
2849
2992
|
return true;
|
|
@@ -2981,6 +3124,7 @@ var $;
|
|
|
2981
3124
|
|
|
2982
3125
|
;
|
|
2983
3126
|
"use strict";
|
|
3127
|
+
/** @jsx $mol_jsx */
|
|
2984
3128
|
var $;
|
|
2985
3129
|
(function ($) {
|
|
2986
3130
|
$mol_test({
|
|
@@ -3042,6 +3186,7 @@ var $;
|
|
|
3042
3186
|
const obj3_copy = { test: 3, obj2: obj2_copy };
|
|
3043
3187
|
obj1.obj3 = obj3;
|
|
3044
3188
|
obj1_copy.obj3 = obj3_copy;
|
|
3189
|
+
// warmup cache
|
|
3045
3190
|
$mol_assert_not($mol_compare_deep(obj1, {}));
|
|
3046
3191
|
$mol_assert_not($mol_compare_deep(obj2, {}));
|
|
3047
3192
|
$mol_assert_not($mol_compare_deep(obj3, {}));
|
|
@@ -3111,18 +3256,34 @@ var $;
|
|
|
3111
3256
|
"use strict";
|
|
3112
3257
|
var $;
|
|
3113
3258
|
(function ($) {
|
|
3259
|
+
/**
|
|
3260
|
+
* Argument must be Truthy
|
|
3261
|
+
* @deprecated use $mol_assert_equal instead
|
|
3262
|
+
*/
|
|
3114
3263
|
function $mol_assert_ok(value) {
|
|
3115
3264
|
if (value)
|
|
3116
3265
|
return;
|
|
3117
3266
|
$mol_fail(new Error(`${value} ≠ true`));
|
|
3118
3267
|
}
|
|
3119
3268
|
$.$mol_assert_ok = $mol_assert_ok;
|
|
3269
|
+
/**
|
|
3270
|
+
* Argument must be Falsy
|
|
3271
|
+
* @deprecated use $mol_assert_equal instead
|
|
3272
|
+
*/
|
|
3120
3273
|
function $mol_assert_not(value) {
|
|
3121
3274
|
if (!value)
|
|
3122
3275
|
return;
|
|
3123
3276
|
$mol_fail(new Error(`${value} ≠ false`));
|
|
3124
3277
|
}
|
|
3125
3278
|
$.$mol_assert_not = $mol_assert_not;
|
|
3279
|
+
/**
|
|
3280
|
+
* Handler must throw an error.
|
|
3281
|
+
* @example
|
|
3282
|
+
* $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } ) // Passes because throws error
|
|
3283
|
+
* $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } , 'Parse error' ) // Passes because throws right message
|
|
3284
|
+
* $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } , Error ) // Passes because throws right class
|
|
3285
|
+
* @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
|
|
3286
|
+
*/
|
|
3126
3287
|
function $mol_assert_fail(handler, ErrorRight) {
|
|
3127
3288
|
const fail = $.$mol_fail;
|
|
3128
3289
|
try {
|
|
@@ -3145,10 +3306,18 @@ var $;
|
|
|
3145
3306
|
$mol_fail(new Error('Not failed', { cause: { expect: ErrorRight } }));
|
|
3146
3307
|
}
|
|
3147
3308
|
$.$mol_assert_fail = $mol_assert_fail;
|
|
3309
|
+
/** @deprecated Use $mol_assert_equal */
|
|
3148
3310
|
function $mol_assert_like(...args) {
|
|
3149
3311
|
$mol_assert_equal(...args);
|
|
3150
3312
|
}
|
|
3151
3313
|
$.$mol_assert_like = $mol_assert_like;
|
|
3314
|
+
/**
|
|
3315
|
+
* All arguments must not be structural equal to each other.
|
|
3316
|
+
* @example
|
|
3317
|
+
* $mol_assert_unique( 1 , 2 , 3 ) // Passes
|
|
3318
|
+
* $mol_assert_unique( 1 , 1 , 2 ) // Fails because 1 === 1
|
|
3319
|
+
* @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
|
|
3320
|
+
*/
|
|
3152
3321
|
function $mol_assert_unique(...args) {
|
|
3153
3322
|
for (let i = 0; i < args.length; ++i) {
|
|
3154
3323
|
for (let j = 0; j < args.length; ++j) {
|
|
@@ -3161,6 +3330,13 @@ var $;
|
|
|
3161
3330
|
}
|
|
3162
3331
|
}
|
|
3163
3332
|
$.$mol_assert_unique = $mol_assert_unique;
|
|
3333
|
+
/**
|
|
3334
|
+
* All arguments must be structural equal each other.
|
|
3335
|
+
* @example
|
|
3336
|
+
* $mol_assert_like( [1] , [1] , [1] ) // Passes
|
|
3337
|
+
* $mol_assert_like( [1] , [1] , [2] ) // Fails because 1 !== 2
|
|
3338
|
+
* @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
|
|
3339
|
+
*/
|
|
3164
3340
|
function $mol_assert_equal(...args) {
|
|
3165
3341
|
for (let i = 1; i < args.length; ++i) {
|
|
3166
3342
|
if ($mol_compare_deep(args[0], args[i]))
|
|
@@ -3214,6 +3390,11 @@ var $;
|
|
|
3214
3390
|
var $;
|
|
3215
3391
|
(function ($) {
|
|
3216
3392
|
const instances = new WeakSet();
|
|
3393
|
+
/**
|
|
3394
|
+
* Proxy that delegates all to lazy returned target.
|
|
3395
|
+
*
|
|
3396
|
+
* $mol_delegate( Array.prototype , ()=> fetch_array() )
|
|
3397
|
+
*/
|
|
3217
3398
|
function $mol_delegate(proto, target) {
|
|
3218
3399
|
const proxy = new Proxy(proto, {
|
|
3219
3400
|
get: (_, field) => {
|
|
@@ -3313,6 +3494,7 @@ var $;
|
|
|
3313
3494
|
"use strict";
|
|
3314
3495
|
var $;
|
|
3315
3496
|
(function ($) {
|
|
3497
|
+
/** Position in any resource. */
|
|
3316
3498
|
class $mol_span extends $mol_object2 {
|
|
3317
3499
|
uri;
|
|
3318
3500
|
source;
|
|
@@ -3328,13 +3510,17 @@ var $;
|
|
|
3328
3510
|
this.length = length;
|
|
3329
3511
|
this[Symbol.toStringTag] = this.uri + ('#' + this.row + ':' + this.col + '/' + this.length);
|
|
3330
3512
|
}
|
|
3513
|
+
/** Span for begin of unknown resource */
|
|
3331
3514
|
static unknown = $mol_span.begin('?');
|
|
3515
|
+
/** Makes new span for begin of resource. */
|
|
3332
3516
|
static begin(uri, source = '') {
|
|
3333
3517
|
return new $mol_span(uri, source, 1, 1, 0);
|
|
3334
3518
|
}
|
|
3519
|
+
/** Makes new span for end of resource. */
|
|
3335
3520
|
static end(uri, source) {
|
|
3336
3521
|
return new $mol_span(uri, source, 1, source.length + 1, 0);
|
|
3337
3522
|
}
|
|
3523
|
+
/** Makes new span for entire resource. */
|
|
3338
3524
|
static entire(uri, source) {
|
|
3339
3525
|
return new $mol_span(uri, source, 1, 1, source.length);
|
|
3340
3526
|
}
|
|
@@ -3349,15 +3535,19 @@ var $;
|
|
|
3349
3535
|
length: this.length
|
|
3350
3536
|
};
|
|
3351
3537
|
}
|
|
3538
|
+
/** Makes new error for this span. */
|
|
3352
3539
|
error(message, Class = Error) {
|
|
3353
3540
|
return new Class(`${message} (${this})`);
|
|
3354
3541
|
}
|
|
3542
|
+
/** Makes new span for same uri. */
|
|
3355
3543
|
span(row, col, length) {
|
|
3356
3544
|
return new $mol_span(this.uri, this.source, row, col, length);
|
|
3357
3545
|
}
|
|
3546
|
+
/** Makes new span after end of this. */
|
|
3358
3547
|
after(length = 0) {
|
|
3359
3548
|
return new $mol_span(this.uri, this.source, this.row, this.col + this.length, length);
|
|
3360
3549
|
}
|
|
3550
|
+
/** Makes new span between begin and end. */
|
|
3361
3551
|
slice(begin, end = -1) {
|
|
3362
3552
|
let len = this.length;
|
|
3363
3553
|
if (begin < 0)
|
|
@@ -3432,6 +3622,7 @@ var $;
|
|
|
3432
3622
|
"use strict";
|
|
3433
3623
|
var $;
|
|
3434
3624
|
(function ($) {
|
|
3625
|
+
/** Serializes tree to string in tree format. */
|
|
3435
3626
|
function $mol_tree2_to_string(tree) {
|
|
3436
3627
|
let output = [];
|
|
3437
3628
|
function dump(tree, prefix = '') {
|
|
@@ -3491,12 +3682,25 @@ var $;
|
|
|
3491
3682
|
"use strict";
|
|
3492
3683
|
var $;
|
|
3493
3684
|
(function ($) {
|
|
3685
|
+
/**
|
|
3686
|
+
* Abstract Syntax Tree with human readable serialization.
|
|
3687
|
+
* Avoid direct instantiation. Use static factories instead.
|
|
3688
|
+
* @see https://github.com/nin-jin/tree.d
|
|
3689
|
+
*/
|
|
3494
3690
|
class $mol_tree2 extends Object {
|
|
3495
3691
|
type;
|
|
3496
3692
|
value;
|
|
3497
3693
|
kids;
|
|
3498
3694
|
span;
|
|
3499
|
-
constructor(
|
|
3695
|
+
constructor(
|
|
3696
|
+
/** Type of structural node, `value` should be empty */
|
|
3697
|
+
type,
|
|
3698
|
+
/** Content of data node, `type` should be empty */
|
|
3699
|
+
value,
|
|
3700
|
+
/** Child nodes */
|
|
3701
|
+
kids,
|
|
3702
|
+
/** Position in most far source resource */
|
|
3703
|
+
span) {
|
|
3500
3704
|
super();
|
|
3501
3705
|
this.type = type;
|
|
3502
3706
|
this.value = value;
|
|
@@ -3504,12 +3708,15 @@ var $;
|
|
|
3504
3708
|
this.span = span;
|
|
3505
3709
|
this[Symbol.toStringTag] = type || '\\' + value;
|
|
3506
3710
|
}
|
|
3711
|
+
/** Makes collection node. */
|
|
3507
3712
|
static list(kids, span = $mol_span.unknown) {
|
|
3508
3713
|
return new $mol_tree2('', '', kids, span);
|
|
3509
3714
|
}
|
|
3715
|
+
/** Makes new derived collection node. */
|
|
3510
3716
|
list(kids) {
|
|
3511
3717
|
return $mol_tree2.list(kids, this.span);
|
|
3512
3718
|
}
|
|
3719
|
+
/** Makes data node for any string. */
|
|
3513
3720
|
static data(value, kids = [], span = $mol_span.unknown) {
|
|
3514
3721
|
const chunks = value.split('\n');
|
|
3515
3722
|
if (chunks.length > 1) {
|
|
@@ -3523,21 +3730,26 @@ var $;
|
|
|
3523
3730
|
}
|
|
3524
3731
|
return new $mol_tree2('', value, kids, span);
|
|
3525
3732
|
}
|
|
3733
|
+
/** Makes new derived data node. */
|
|
3526
3734
|
data(value, kids = []) {
|
|
3527
3735
|
return $mol_tree2.data(value, kids, this.span);
|
|
3528
3736
|
}
|
|
3737
|
+
/** Makes struct node. */
|
|
3529
3738
|
static struct(type, kids = [], span = $mol_span.unknown) {
|
|
3530
3739
|
if (/[ \n\t\\]/.test(type)) {
|
|
3531
3740
|
$$.$mol_fail(span.error(`Wrong type ${JSON.stringify(type)}`));
|
|
3532
3741
|
}
|
|
3533
3742
|
return new $mol_tree2(type, '', kids, span);
|
|
3534
3743
|
}
|
|
3744
|
+
/** Makes new derived structural node. */
|
|
3535
3745
|
struct(type, kids = []) {
|
|
3536
3746
|
return $mol_tree2.struct(type, kids, this.span);
|
|
3537
3747
|
}
|
|
3748
|
+
/** Makes new derived node with different kids id defined. */
|
|
3538
3749
|
clone(kids, span = this.span) {
|
|
3539
3750
|
return new $mol_tree2(this.type, this.value, kids, span);
|
|
3540
3751
|
}
|
|
3752
|
+
/** Returns multiline text content. */
|
|
3541
3753
|
text() {
|
|
3542
3754
|
var values = [];
|
|
3543
3755
|
for (var kid of this.kids) {
|
|
@@ -3547,15 +3759,20 @@ var $;
|
|
|
3547
3759
|
}
|
|
3548
3760
|
return this.value + values.join('\n');
|
|
3549
3761
|
}
|
|
3762
|
+
/** Parses tree format. */
|
|
3763
|
+
/** @deprecated Use $mol_tree2_from_string */
|
|
3550
3764
|
static fromString(str, uri = 'unknown') {
|
|
3551
3765
|
return $$.$mol_tree2_from_string(str, uri);
|
|
3552
3766
|
}
|
|
3767
|
+
/** Serializes to tree format. */
|
|
3553
3768
|
toString() {
|
|
3554
3769
|
return $$.$mol_tree2_to_string(this);
|
|
3555
3770
|
}
|
|
3771
|
+
/** Makes new tree with node overrided by path. */
|
|
3556
3772
|
insert(value, ...path) {
|
|
3557
3773
|
return this.update($mol_maybe(value), ...path)[0];
|
|
3558
3774
|
}
|
|
3775
|
+
/** Makes new tree with node overrided by path. */
|
|
3559
3776
|
update(value, ...path) {
|
|
3560
3777
|
if (path.length === 0)
|
|
3561
3778
|
return value;
|
|
@@ -3588,6 +3805,7 @@ var $;
|
|
|
3588
3805
|
return [this.clone(kids)];
|
|
3589
3806
|
}
|
|
3590
3807
|
}
|
|
3808
|
+
/** Query nodes by path. */
|
|
3591
3809
|
select(...path) {
|
|
3592
3810
|
let next = [this];
|
|
3593
3811
|
for (const type of path) {
|
|
@@ -3614,6 +3832,7 @@ var $;
|
|
|
3614
3832
|
}
|
|
3615
3833
|
return this.list(next);
|
|
3616
3834
|
}
|
|
3835
|
+
/** Filter kids by path or value. */
|
|
3617
3836
|
filter(path, value) {
|
|
3618
3837
|
const sub = this.kids.filter(item => {
|
|
3619
3838
|
var found = item.select(...path);
|
|
@@ -3641,9 +3860,11 @@ var $;
|
|
|
3641
3860
|
$mol_fail_hidden(error);
|
|
3642
3861
|
}
|
|
3643
3862
|
}
|
|
3863
|
+
/** Transform tree through context with transformers */
|
|
3644
3864
|
hack(belt, context = {}) {
|
|
3645
3865
|
return [].concat(...this.kids.map(child => child.hack_self(belt, context)));
|
|
3646
3866
|
}
|
|
3867
|
+
/** Makes Error with node coordinates. */
|
|
3647
3868
|
error(message, Class = Error) {
|
|
3648
3869
|
return this.span.error(`${message}\n${this.clone([])}`, Class);
|
|
3649
3870
|
}
|
|
@@ -3799,6 +4020,7 @@ var $;
|
|
|
3799
4020
|
"use strict";
|
|
3800
4021
|
var $;
|
|
3801
4022
|
(function ($) {
|
|
4023
|
+
/** Syntax error with cordinates and source line snippet. */
|
|
3802
4024
|
class $mol_error_syntax extends SyntaxError {
|
|
3803
4025
|
reason;
|
|
3804
4026
|
line;
|
|
@@ -3817,6 +4039,7 @@ var $;
|
|
|
3817
4039
|
"use strict";
|
|
3818
4040
|
var $;
|
|
3819
4041
|
(function ($) {
|
|
4042
|
+
/** Parses tree format from string. */
|
|
3820
4043
|
function $mol_tree2_from_string(str, uri = '?') {
|
|
3821
4044
|
const span = $mol_span.entire(uri, str);
|
|
3822
4045
|
var root = $mol_tree2.list([], span);
|
|
@@ -3826,6 +4049,7 @@ var $;
|
|
|
3826
4049
|
var indent = 0;
|
|
3827
4050
|
var line_start = pos;
|
|
3828
4051
|
row++;
|
|
4052
|
+
// read indent
|
|
3829
4053
|
while (str.length > pos && str[pos] == '\t') {
|
|
3830
4054
|
indent++;
|
|
3831
4055
|
pos++;
|
|
@@ -3834,8 +4058,10 @@ var $;
|
|
|
3834
4058
|
min_indent = indent;
|
|
3835
4059
|
}
|
|
3836
4060
|
indent -= min_indent;
|
|
4061
|
+
// invalid tab size
|
|
3837
4062
|
if (indent < 0 || indent >= stack.length) {
|
|
3838
4063
|
const sp = span.span(row, 1, pos - line_start);
|
|
4064
|
+
// skip error line
|
|
3839
4065
|
while (str.length > pos && str[pos] != '\n') {
|
|
3840
4066
|
pos++;
|
|
3841
4067
|
}
|
|
@@ -3850,7 +4076,9 @@ var $;
|
|
|
3850
4076
|
}
|
|
3851
4077
|
stack.length = indent + 1;
|
|
3852
4078
|
var parent = stack[indent];
|
|
4079
|
+
// parse types
|
|
3853
4080
|
while (str.length > pos && str[pos] != '\\' && str[pos] != '\n') {
|
|
4081
|
+
// type can not contain space and tab
|
|
3854
4082
|
var error_start = pos;
|
|
3855
4083
|
while (str.length > pos && (str[pos] == ' ' || str[pos] == '\t')) {
|
|
3856
4084
|
pos++;
|
|
@@ -3862,6 +4090,7 @@ var $;
|
|
|
3862
4090
|
const sp = span.span(row, error_start - line_start + 1, pos - error_start);
|
|
3863
4091
|
this.$mol_fail(new this.$mol_error_syntax(`Wrong nodes separator`, str.substring(line_start, line_end), sp));
|
|
3864
4092
|
}
|
|
4093
|
+
// read type
|
|
3865
4094
|
var type_start = pos;
|
|
3866
4095
|
while (str.length > pos &&
|
|
3867
4096
|
str[pos] != '\\' &&
|
|
@@ -3876,10 +4105,12 @@ var $;
|
|
|
3876
4105
|
parent_kids.push(next);
|
|
3877
4106
|
parent = next;
|
|
3878
4107
|
}
|
|
4108
|
+
// read one space if exists
|
|
3879
4109
|
if (str.length > pos && str[pos] == ' ') {
|
|
3880
4110
|
pos++;
|
|
3881
4111
|
}
|
|
3882
4112
|
}
|
|
4113
|
+
// read data
|
|
3883
4114
|
if (str.length > pos && str[pos] == '\\') {
|
|
3884
4115
|
var data_start = pos;
|
|
3885
4116
|
while (str.length > pos && str[pos] != '\n') {
|
|
@@ -3890,6 +4121,7 @@ var $;
|
|
|
3890
4121
|
parent_kids.push(next);
|
|
3891
4122
|
parent = next;
|
|
3892
4123
|
}
|
|
4124
|
+
// now must be end of text
|
|
3893
4125
|
if (str.length === pos && stack.length > 0) {
|
|
3894
4126
|
const sp = span.span(row, pos - line_start + 1, 1);
|
|
3895
4127
|
this.$mol_fail(new this.$mol_error_syntax(`Unexpected EOF, LF required`, str.substring(line_start, str.length), sp));
|
|
@@ -4082,6 +4314,12 @@ var $;
|
|
|
4082
4314
|
'return result without errors'() {
|
|
4083
4315
|
$mol_assert_equal($mol_try(() => false), false);
|
|
4084
4316
|
},
|
|
4317
|
+
//'return error if thrown'() {
|
|
4318
|
+
//
|
|
4319
|
+
// const error = new Error( '$mol_try test error' )
|
|
4320
|
+
// $mol_assert_equal( $mol_try( ()=> { throw error } ) , error )
|
|
4321
|
+
//
|
|
4322
|
+
//} ,
|
|
4085
4323
|
});
|
|
4086
4324
|
})($ || ($ = {}));
|
|
4087
4325
|
|