mol_regexp 0.0.260 → 0.0.261
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 +0 -119
- package/node.deps.json +1 -1
- package/node.esm.js +11 -11
- package/node.esm.js.map +1 -1
- package/node.js +11 -11
- package/node.js.map +1 -1
- package/node.test.js +333 -327
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/test.html +2 -2
- package/web.d.ts +0 -119
- package/web.deps.json +1 -1
- package/web.esm.js +11 -11
- package/web.esm.js.map +1 -1
- package/web.js +11 -11
- package/web.js.map +1 -1
- package/web.test.js +246 -240
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -19,19 +19,19 @@ var $;
|
|
|
19
19
|
(function ($) {
|
|
20
20
|
})($ || ($ = {}));
|
|
21
21
|
module.exports = $;
|
|
22
|
-
//mam.
|
|
22
|
+
//mam.ts
|
|
23
23
|
;
|
|
24
24
|
"use strict";
|
|
25
|
-
//equals.
|
|
25
|
+
//mol/type/equals/equals.ts
|
|
26
26
|
;
|
|
27
27
|
"use strict";
|
|
28
|
-
//merge.
|
|
28
|
+
//mol/type/merge/merge.ts
|
|
29
29
|
;
|
|
30
30
|
"use strict";
|
|
31
|
-
//intersect.
|
|
31
|
+
//mol/type/intersect/intersect.ts
|
|
32
32
|
;
|
|
33
33
|
"use strict";
|
|
34
|
-
//override.
|
|
34
|
+
//mol/type/override/override.ts
|
|
35
35
|
;
|
|
36
36
|
"use strict";
|
|
37
37
|
var $;
|
|
@@ -41,10 +41,10 @@ var $;
|
|
|
41
41
|
}
|
|
42
42
|
$.$mol_fail = $mol_fail;
|
|
43
43
|
})($ || ($ = {}));
|
|
44
|
-
//fail.
|
|
44
|
+
//mol/fail/fail.ts
|
|
45
45
|
;
|
|
46
46
|
"use strict";
|
|
47
|
-
//unicode.
|
|
47
|
+
//mol/unicode/unicode.ts
|
|
48
48
|
;
|
|
49
49
|
"use strict";
|
|
50
50
|
var $;
|
|
@@ -107,7 +107,7 @@ var $;
|
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
if (from === this.lastIndex) {
|
|
110
|
-
|
|
110
|
+
$mol_fail(new Error('Captured empty substring'));
|
|
111
111
|
}
|
|
112
112
|
const groups = {};
|
|
113
113
|
const skipped = str.slice(from, this.lastIndex - res[0].length);
|
|
@@ -252,7 +252,7 @@ var $;
|
|
|
252
252
|
const str = String(params[option]);
|
|
253
253
|
if (str.match(validator))
|
|
254
254
|
return str;
|
|
255
|
-
|
|
255
|
+
$mol_fail(new Error(`Wrong param: ${option}=${str}`));
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
else {
|
|
@@ -307,7 +307,7 @@ var $;
|
|
|
307
307
|
}
|
|
308
308
|
$.$mol_regexp = $mol_regexp;
|
|
309
309
|
})($ || ($ = {}));
|
|
310
|
-
//regexp.
|
|
310
|
+
//mol/regexp/regexp.ts
|
|
311
311
|
;
|
|
312
312
|
"use strict";
|
|
313
313
|
var $;
|
|
@@ -317,7 +317,7 @@ var $;
|
|
|
317
317
|
}
|
|
318
318
|
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
319
319
|
})($ || ($ = {}));
|
|
320
|
-
//hidden.
|
|
320
|
+
//mol/fail/hidden/hidden.ts
|
|
321
321
|
;
|
|
322
322
|
"use strict";
|
|
323
323
|
var $;
|
|
@@ -327,7 +327,7 @@ var $;
|
|
|
327
327
|
}
|
|
328
328
|
$.$mol_test_complete = $mol_test_complete;
|
|
329
329
|
})($ || ($ = {}));
|
|
330
|
-
//test.node.test.
|
|
330
|
+
//mol/test/test.node.test.ts
|
|
331
331
|
;
|
|
332
332
|
"use strict";
|
|
333
333
|
var $;
|
|
@@ -345,12 +345,18 @@ var $;
|
|
|
345
345
|
$_1.$mol_test_all = [];
|
|
346
346
|
async function $mol_test_run() {
|
|
347
347
|
for (var test of $_1.$mol_test_all) {
|
|
348
|
-
let context = Object.create(
|
|
348
|
+
let context = Object.create($$);
|
|
349
349
|
for (let mock of $_1.$mol_test_mocks)
|
|
350
350
|
await mock(context);
|
|
351
|
-
|
|
351
|
+
const res = test(context);
|
|
352
|
+
if (res instanceof Promise) {
|
|
353
|
+
await new Promise((done, fail) => {
|
|
354
|
+
res.then(done, fail);
|
|
355
|
+
setTimeout(() => fail(new Error('Test timeout: ' + test.name)), 1000);
|
|
356
|
+
});
|
|
357
|
+
}
|
|
352
358
|
}
|
|
353
|
-
|
|
359
|
+
$$.$mol_log3_done({
|
|
354
360
|
place: '$mol_test',
|
|
355
361
|
message: 'All tests passed',
|
|
356
362
|
count: $_1.$mol_test_all.length,
|
|
@@ -368,7 +374,7 @@ var $;
|
|
|
368
374
|
await $mol_test_run();
|
|
369
375
|
}
|
|
370
376
|
finally {
|
|
371
|
-
|
|
377
|
+
$$.$mol_test_complete();
|
|
372
378
|
}
|
|
373
379
|
}, 0);
|
|
374
380
|
}
|
|
@@ -381,10 +387,10 @@ var $;
|
|
|
381
387
|
for (let api of forbidden) {
|
|
382
388
|
context[api] = new Proxy(function () { }, {
|
|
383
389
|
get() {
|
|
384
|
-
$
|
|
390
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
385
391
|
},
|
|
386
392
|
apply() {
|
|
387
|
-
$
|
|
393
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
388
394
|
},
|
|
389
395
|
});
|
|
390
396
|
}
|
|
@@ -412,16 +418,16 @@ var $;
|
|
|
412
418
|
},
|
|
413
419
|
});
|
|
414
420
|
})($ || ($ = {}));
|
|
415
|
-
//test.test.
|
|
421
|
+
//mol/test/test.test.ts
|
|
416
422
|
;
|
|
417
423
|
"use strict";
|
|
418
424
|
var $;
|
|
419
425
|
(function ($) {
|
|
420
426
|
})($ || ($ = {}));
|
|
421
|
-
//context.
|
|
427
|
+
//mol/dom/context/context.ts
|
|
422
428
|
;
|
|
423
429
|
"use strict";
|
|
424
|
-
//node.
|
|
430
|
+
//node/node.ts
|
|
425
431
|
;
|
|
426
432
|
"use strict";
|
|
427
433
|
var $node = new Proxy({ require }, {
|
|
@@ -460,14 +466,14 @@ var $node = new Proxy({ require }, {
|
|
|
460
466
|
require = (req => Object.assign(function require(name) {
|
|
461
467
|
return $node[name];
|
|
462
468
|
}, req))(require);
|
|
463
|
-
//node.node.
|
|
469
|
+
//node/node.node.ts
|
|
464
470
|
;
|
|
465
471
|
"use strict";
|
|
466
472
|
var $;
|
|
467
473
|
(function ($) {
|
|
468
474
|
$.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
|
|
469
475
|
})($ || ($ = {}));
|
|
470
|
-
//context.node.
|
|
476
|
+
//mol/dom/context/context.node.ts
|
|
471
477
|
;
|
|
472
478
|
"use strict";
|
|
473
479
|
var $;
|
|
@@ -478,7 +484,7 @@ var $;
|
|
|
478
484
|
for (let view of childNodes) {
|
|
479
485
|
if (view == null)
|
|
480
486
|
continue;
|
|
481
|
-
if (view instanceof
|
|
487
|
+
if (view instanceof $mol_dom_context.Node) {
|
|
482
488
|
while (true) {
|
|
483
489
|
if (!nextNode) {
|
|
484
490
|
el.appendChild(view);
|
|
@@ -509,7 +515,7 @@ var $;
|
|
|
509
515
|
nextNode = nextNode.nextSibling;
|
|
510
516
|
}
|
|
511
517
|
else {
|
|
512
|
-
const textNode =
|
|
518
|
+
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
|
513
519
|
el.insertBefore(textNode, nextNode);
|
|
514
520
|
}
|
|
515
521
|
}
|
|
@@ -522,88 +528,88 @@ var $;
|
|
|
522
528
|
}
|
|
523
529
|
$.$mol_dom_render_children = $mol_dom_render_children;
|
|
524
530
|
})($ || ($ = {}));
|
|
525
|
-
//children.
|
|
531
|
+
//mol/dom/render/children/children.ts
|
|
526
532
|
;
|
|
527
533
|
"use strict";
|
|
528
|
-
//error.
|
|
534
|
+
//mol/type/error/error.ts
|
|
529
535
|
;
|
|
530
536
|
"use strict";
|
|
531
|
-
//assert.test.
|
|
537
|
+
//mol/type/assert/assert.test.ts
|
|
532
538
|
;
|
|
533
539
|
"use strict";
|
|
534
|
-
//assert.
|
|
540
|
+
//mol/type/assert/assert.ts
|
|
535
541
|
;
|
|
536
542
|
"use strict";
|
|
537
|
-
//deep.test.
|
|
543
|
+
//mol/type/partial/deep/deep.test.ts
|
|
538
544
|
;
|
|
539
545
|
"use strict";
|
|
540
|
-
//deep.
|
|
546
|
+
//mol/type/partial/deep/deep.ts
|
|
541
547
|
;
|
|
542
548
|
"use strict";
|
|
543
549
|
var $;
|
|
544
550
|
(function ($) {
|
|
545
|
-
|
|
551
|
+
$mol_test({
|
|
546
552
|
'Make empty div'() {
|
|
547
|
-
|
|
553
|
+
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
|
548
554
|
},
|
|
549
555
|
'Define native field'() {
|
|
550
|
-
const dom =
|
|
551
|
-
|
|
552
|
-
|
|
556
|
+
const dom = $mol_jsx("input", { value: '123' });
|
|
557
|
+
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
558
|
+
$mol_assert_equal(dom.value, '123');
|
|
553
559
|
},
|
|
554
560
|
'Define classes'() {
|
|
555
|
-
const dom =
|
|
556
|
-
|
|
561
|
+
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
562
|
+
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
557
563
|
},
|
|
558
564
|
'Define styles'() {
|
|
559
|
-
const dom =
|
|
560
|
-
|
|
565
|
+
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
566
|
+
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
561
567
|
},
|
|
562
568
|
'Define dataset'() {
|
|
563
|
-
const dom =
|
|
564
|
-
|
|
569
|
+
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
570
|
+
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
565
571
|
},
|
|
566
572
|
'Define attributes'() {
|
|
567
|
-
const dom =
|
|
568
|
-
|
|
573
|
+
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
574
|
+
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
569
575
|
},
|
|
570
576
|
'Define child nodes'() {
|
|
571
|
-
const dom =
|
|
577
|
+
const dom = $mol_jsx("div", null,
|
|
572
578
|
"hello",
|
|
573
|
-
|
|
579
|
+
$mol_jsx("strong", null, "world"),
|
|
574
580
|
"!");
|
|
575
|
-
|
|
581
|
+
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
576
582
|
},
|
|
577
583
|
'Function as component'() {
|
|
578
584
|
const Button = ({ hint }, target) => {
|
|
579
|
-
return
|
|
585
|
+
return $mol_jsx("button", { title: hint }, target());
|
|
580
586
|
};
|
|
581
|
-
const dom =
|
|
582
|
-
|
|
587
|
+
const dom = $mol_jsx(Button, { id: "/foo", hint: "click me" }, () => 'hey!');
|
|
588
|
+
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="/foo">hey!</button>');
|
|
583
589
|
},
|
|
584
590
|
'Nested guid generation'() {
|
|
585
591
|
const Foo = () => {
|
|
586
|
-
return
|
|
587
|
-
|
|
588
|
-
|
|
592
|
+
return $mol_jsx("div", null,
|
|
593
|
+
$mol_jsx(Bar, { id: "/bar" },
|
|
594
|
+
$mol_jsx("img", { id: "/icon" })));
|
|
589
595
|
};
|
|
590
596
|
const Bar = (props, icon) => {
|
|
591
|
-
return
|
|
597
|
+
return $mol_jsx("span", null, icon);
|
|
592
598
|
};
|
|
593
|
-
const dom =
|
|
594
|
-
|
|
599
|
+
const dom = $mol_jsx(Foo, { id: "/foo" });
|
|
600
|
+
$mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
|
|
595
601
|
},
|
|
596
602
|
'Fail on non unique ids'() {
|
|
597
603
|
const App = () => {
|
|
598
|
-
return
|
|
599
|
-
|
|
600
|
-
|
|
604
|
+
return $mol_jsx("div", null,
|
|
605
|
+
$mol_jsx("span", { id: "/bar" }),
|
|
606
|
+
$mol_jsx("span", { id: "/bar" }));
|
|
601
607
|
};
|
|
602
|
-
|
|
608
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
|
|
603
609
|
},
|
|
604
610
|
});
|
|
605
611
|
})($ || ($ = {}));
|
|
606
|
-
//jsx.test.
|
|
612
|
+
//mol/jsx/jsx.test.tsx
|
|
607
613
|
;
|
|
608
614
|
"use strict";
|
|
609
615
|
var $;
|
|
@@ -612,15 +618,15 @@ var $;
|
|
|
612
618
|
$.$mol_jsx_booked = null;
|
|
613
619
|
$.$mol_jsx_document = {
|
|
614
620
|
getElementById: () => null,
|
|
615
|
-
createElementNS: (space, name) =>
|
|
616
|
-
createDocumentFragment: () =>
|
|
621
|
+
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
|
622
|
+
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
617
623
|
};
|
|
618
624
|
$.$mol_jsx_frag = '';
|
|
619
625
|
function $mol_jsx(Elem, props, ...childNodes) {
|
|
620
626
|
const id = props && props.id || '';
|
|
621
627
|
if (Elem && $.$mol_jsx_booked) {
|
|
622
628
|
if ($.$mol_jsx_booked.has(id)) {
|
|
623
|
-
|
|
629
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
|
|
624
630
|
}
|
|
625
631
|
else {
|
|
626
632
|
$.$mol_jsx_booked.add(id);
|
|
@@ -659,7 +665,7 @@ var $;
|
|
|
659
665
|
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
660
666
|
: $.$mol_jsx_document.createDocumentFragment();
|
|
661
667
|
}
|
|
662
|
-
|
|
668
|
+
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
663
669
|
if (!Elem)
|
|
664
670
|
return node;
|
|
665
671
|
for (const key in props) {
|
|
@@ -685,77 +691,77 @@ var $;
|
|
|
685
691
|
}
|
|
686
692
|
$.$mol_jsx = $mol_jsx;
|
|
687
693
|
})($ || ($ = {}));
|
|
688
|
-
//jsx.
|
|
694
|
+
//mol/jsx/jsx.ts
|
|
689
695
|
;
|
|
690
696
|
"use strict";
|
|
691
697
|
var $;
|
|
692
698
|
(function ($) {
|
|
693
|
-
|
|
699
|
+
$mol_test({
|
|
694
700
|
'nulls & undefineds'() {
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
701
|
+
$mol_assert_ok($mol_compare_deep(null, null));
|
|
702
|
+
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
703
|
+
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
704
|
+
$mol_assert_not($mol_compare_deep({}, null));
|
|
699
705
|
},
|
|
700
706
|
'number'() {
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
707
|
+
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
708
|
+
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
709
|
+
$mol_assert_not($mol_compare_deep(1, 2));
|
|
710
|
+
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
711
|
+
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
706
712
|
},
|
|
707
713
|
'POJO'() {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
+
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
715
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
716
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
717
|
+
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
718
|
+
$mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
719
|
+
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
714
720
|
},
|
|
715
721
|
'Array'() {
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
722
|
+
$mol_assert_ok($mol_compare_deep([], []));
|
|
723
|
+
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
724
|
+
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
725
|
+
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
720
726
|
},
|
|
721
727
|
'Non POJO are different'() {
|
|
722
728
|
class Thing extends Object {
|
|
723
729
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
730
|
+
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
731
|
+
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
732
|
+
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
727
733
|
},
|
|
728
734
|
'same POJOs with cyclic reference'() {
|
|
729
735
|
const a = { foo: {} };
|
|
730
736
|
a['self'] = a;
|
|
731
737
|
const b = { foo: {} };
|
|
732
738
|
b['self'] = b;
|
|
733
|
-
|
|
739
|
+
$mol_assert_ok($mol_compare_deep(a, b));
|
|
734
740
|
},
|
|
735
741
|
'Date'() {
|
|
736
|
-
|
|
737
|
-
|
|
742
|
+
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
743
|
+
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
738
744
|
},
|
|
739
745
|
'RegExp'() {
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
746
|
+
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
747
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
748
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
743
749
|
},
|
|
744
750
|
'Map'() {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
751
|
+
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
752
|
+
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
753
|
+
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
754
|
+
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
749
755
|
},
|
|
750
756
|
'Set'() {
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
757
|
+
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
758
|
+
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
759
|
+
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
754
760
|
},
|
|
755
761
|
'Uint8Array'() {
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
762
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
763
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
764
|
+
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
759
765
|
},
|
|
760
766
|
'Custom comparator'() {
|
|
761
767
|
class User {
|
|
@@ -769,17 +775,17 @@ var $;
|
|
|
769
775
|
return this.name;
|
|
770
776
|
}
|
|
771
777
|
}
|
|
772
|
-
|
|
773
|
-
|
|
778
|
+
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
779
|
+
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
774
780
|
},
|
|
775
781
|
});
|
|
776
782
|
})($ || ($ = {}));
|
|
777
|
-
//deep.test.
|
|
783
|
+
//mol/compare/deep/deep.test.tsx
|
|
778
784
|
;
|
|
779
785
|
"use strict";
|
|
780
786
|
var $;
|
|
781
787
|
(function ($) {
|
|
782
|
-
|
|
788
|
+
$.$mol_compare_deep_cache = new WeakMap();
|
|
783
789
|
function $mol_compare_deep(left, right) {
|
|
784
790
|
if (Object.is(left, right))
|
|
785
791
|
return true;
|
|
@@ -805,7 +811,7 @@ var $;
|
|
|
805
811
|
return Object.is(left.valueOf(), right['valueOf']());
|
|
806
812
|
if (left instanceof RegExp)
|
|
807
813
|
return left.source === right['source'] && left.flags === right['flags'];
|
|
808
|
-
let left_cache =
|
|
814
|
+
let left_cache = $.$mol_compare_deep_cache.get(left);
|
|
809
815
|
if (left_cache) {
|
|
810
816
|
const right_cache = left_cache.get(right);
|
|
811
817
|
if (typeof right_cache === 'boolean')
|
|
@@ -813,7 +819,7 @@ var $;
|
|
|
813
819
|
}
|
|
814
820
|
else {
|
|
815
821
|
left_cache = new WeakMap([[right, true]]);
|
|
816
|
-
|
|
822
|
+
$.$mol_compare_deep_cache.set(left, left_cache);
|
|
817
823
|
}
|
|
818
824
|
let result;
|
|
819
825
|
try {
|
|
@@ -897,50 +903,50 @@ var $;
|
|
|
897
903
|
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
898
904
|
}
|
|
899
905
|
})($ || ($ = {}));
|
|
900
|
-
//deep.
|
|
906
|
+
//mol/compare/deep/deep.ts
|
|
901
907
|
;
|
|
902
908
|
"use strict";
|
|
903
909
|
var $;
|
|
904
910
|
(function ($) {
|
|
905
911
|
function $mol_dom_serialize(node) {
|
|
906
|
-
const serializer = new
|
|
912
|
+
const serializer = new $mol_dom_context.XMLSerializer;
|
|
907
913
|
return serializer.serializeToString(node);
|
|
908
914
|
}
|
|
909
915
|
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
910
916
|
})($ || ($ = {}));
|
|
911
|
-
//serialize.
|
|
917
|
+
//mol/dom/serialize/serialize.ts
|
|
912
918
|
;
|
|
913
919
|
"use strict";
|
|
914
920
|
var $;
|
|
915
921
|
(function ($) {
|
|
916
|
-
|
|
922
|
+
$mol_test({
|
|
917
923
|
'must be false'() {
|
|
918
|
-
|
|
924
|
+
$mol_assert_not(0);
|
|
919
925
|
},
|
|
920
926
|
'must be true'() {
|
|
921
|
-
|
|
927
|
+
$mol_assert_ok(1);
|
|
922
928
|
},
|
|
923
929
|
'two must be equal'() {
|
|
924
|
-
|
|
930
|
+
$mol_assert_equal(2, 2);
|
|
925
931
|
},
|
|
926
932
|
'three must be equal'() {
|
|
927
|
-
|
|
933
|
+
$mol_assert_equal(2, 2, 2);
|
|
928
934
|
},
|
|
929
935
|
'two must be unique'() {
|
|
930
|
-
|
|
936
|
+
$mol_assert_unique([3], [3]);
|
|
931
937
|
},
|
|
932
938
|
'three must be unique'() {
|
|
933
|
-
|
|
939
|
+
$mol_assert_unique([3], [3], [3]);
|
|
934
940
|
},
|
|
935
941
|
'two must be alike'() {
|
|
936
|
-
|
|
942
|
+
$mol_assert_like([3], [3]);
|
|
937
943
|
},
|
|
938
944
|
'three must be alike'() {
|
|
939
|
-
|
|
945
|
+
$mol_assert_like([3], [3], [3]);
|
|
940
946
|
},
|
|
941
947
|
});
|
|
942
948
|
})($ || ($ = {}));
|
|
943
|
-
//assert.test.
|
|
949
|
+
//mol/assert/assert.test.ts
|
|
944
950
|
;
|
|
945
951
|
"use strict";
|
|
946
952
|
var $;
|
|
@@ -948,13 +954,13 @@ var $;
|
|
|
948
954
|
function $mol_assert_ok(value) {
|
|
949
955
|
if (value)
|
|
950
956
|
return;
|
|
951
|
-
|
|
957
|
+
$mol_fail(new Error(`${value} ≠ true`));
|
|
952
958
|
}
|
|
953
959
|
$.$mol_assert_ok = $mol_assert_ok;
|
|
954
960
|
function $mol_assert_not(value) {
|
|
955
961
|
if (!value)
|
|
956
962
|
return;
|
|
957
|
-
|
|
963
|
+
$mol_fail(new Error(`${value} ≠ false`));
|
|
958
964
|
}
|
|
959
965
|
$.$mol_assert_not = $mol_assert_not;
|
|
960
966
|
function $mol_assert_fail(handler, ErrorRight) {
|
|
@@ -978,7 +984,7 @@ var $;
|
|
|
978
984
|
finally {
|
|
979
985
|
$.$mol_fail = fail;
|
|
980
986
|
}
|
|
981
|
-
|
|
987
|
+
$mol_fail(new Error('Not failed'));
|
|
982
988
|
}
|
|
983
989
|
$.$mol_assert_fail = $mol_assert_fail;
|
|
984
990
|
function $mol_assert_equal(...args) {
|
|
@@ -989,7 +995,7 @@ var $;
|
|
|
989
995
|
if (Number.isNaN(args[i]) && Number.isNaN(args[j]))
|
|
990
996
|
continue;
|
|
991
997
|
if (args[i] !== args[j])
|
|
992
|
-
|
|
998
|
+
$mol_fail(new Error(`Not equal (${i + 1}:${j + 1})\n${args[i]}\n${args[j]}`));
|
|
993
999
|
}
|
|
994
1000
|
}
|
|
995
1001
|
}
|
|
@@ -1000,7 +1006,7 @@ var $;
|
|
|
1000
1006
|
if (i === j)
|
|
1001
1007
|
continue;
|
|
1002
1008
|
if (args[i] === args[j] || (Number.isNaN(args[i]) && Number.isNaN(args[j]))) {
|
|
1003
|
-
|
|
1009
|
+
$mol_fail(new Error(`args[${i}] = args[${j}] = ${args[i]}`));
|
|
1004
1010
|
}
|
|
1005
1011
|
}
|
|
1006
1012
|
}
|
|
@@ -1008,7 +1014,7 @@ var $;
|
|
|
1008
1014
|
$.$mol_assert_unique = $mol_assert_unique;
|
|
1009
1015
|
function $mol_assert_like(head, ...tail) {
|
|
1010
1016
|
for (let [index, value] of Object.entries(tail)) {
|
|
1011
|
-
if (
|
|
1017
|
+
if (!$mol_compare_deep(value, head)) {
|
|
1012
1018
|
const print = (val) => {
|
|
1013
1019
|
if (!val)
|
|
1014
1020
|
return val;
|
|
@@ -1024,128 +1030,128 @@ var $;
|
|
|
1024
1030
|
return val;
|
|
1025
1031
|
}
|
|
1026
1032
|
};
|
|
1027
|
-
return
|
|
1033
|
+
return $mol_fail(new Error(`Not like (1:${+index + 2})\n${print(head)}\n---\n${print(value)}`));
|
|
1028
1034
|
}
|
|
1029
1035
|
}
|
|
1030
1036
|
}
|
|
1031
1037
|
$.$mol_assert_like = $mol_assert_like;
|
|
1032
1038
|
function $mol_assert_dom(left, right) {
|
|
1033
|
-
$mol_assert_equal(
|
|
1039
|
+
$mol_assert_equal($mol_dom_serialize(left), $mol_dom_serialize(right));
|
|
1034
1040
|
}
|
|
1035
1041
|
$.$mol_assert_dom = $mol_assert_dom;
|
|
1036
1042
|
})($ || ($ = {}));
|
|
1037
|
-
//assert.
|
|
1043
|
+
//mol/assert/assert.ts
|
|
1038
1044
|
;
|
|
1039
1045
|
"use strict";
|
|
1040
|
-
//equals.test.
|
|
1046
|
+
//mol/type/equals/equals.test.ts
|
|
1041
1047
|
;
|
|
1042
1048
|
"use strict";
|
|
1043
|
-
//merge.test.
|
|
1049
|
+
//mol/type/merge/merge.test.ts
|
|
1044
1050
|
;
|
|
1045
1051
|
"use strict";
|
|
1046
|
-
//intersect.test.
|
|
1052
|
+
//mol/type/intersect/intersect.test.ts
|
|
1047
1053
|
;
|
|
1048
1054
|
"use strict";
|
|
1049
1055
|
var $;
|
|
1050
1056
|
(function ($) {
|
|
1051
|
-
|
|
1057
|
+
$mol_test({
|
|
1052
1058
|
'escape'() {
|
|
1053
|
-
const specials =
|
|
1054
|
-
|
|
1059
|
+
const specials = $mol_regexp.from('.*+?^${}()|[]\\');
|
|
1060
|
+
$mol_assert_equal(specials.source, '\\.\\*\\+\\?\\^\\$\\{\\}\\(\\)\\|\\[\\]\\\\');
|
|
1055
1061
|
},
|
|
1056
1062
|
'char code'() {
|
|
1057
|
-
const space =
|
|
1058
|
-
|
|
1063
|
+
const space = $mol_regexp.from(32);
|
|
1064
|
+
$mol_assert_like(' '.match(space), [' ']);
|
|
1059
1065
|
},
|
|
1060
1066
|
'repeat fixed'() {
|
|
1061
|
-
const { repeat, decimal_only: digit } =
|
|
1067
|
+
const { repeat, decimal_only: digit } = $mol_regexp;
|
|
1062
1068
|
const year = repeat(digit, 4, 4);
|
|
1063
|
-
|
|
1069
|
+
$mol_assert_like('#2020#'.match(year), ['2020']);
|
|
1064
1070
|
},
|
|
1065
1071
|
'greedy repeat'() {
|
|
1066
|
-
const { repeat, repeat_greedy, latin_only: letter } =
|
|
1067
|
-
|
|
1068
|
-
|
|
1072
|
+
const { repeat, repeat_greedy, latin_only: letter } = $mol_regexp;
|
|
1073
|
+
$mol_assert_like('abc'.match(repeat(letter, 1, 2)), ['a', 'b', 'c']);
|
|
1074
|
+
$mol_assert_like('abc'.match(repeat_greedy(letter, 1, 2)), ['ab', 'c']);
|
|
1069
1075
|
},
|
|
1070
1076
|
'repeat range'() {
|
|
1071
|
-
const { repeat_greedy, decimal_only: digit } =
|
|
1077
|
+
const { repeat_greedy, decimal_only: digit } = $mol_regexp;
|
|
1072
1078
|
const year = repeat_greedy(digit, 2, 4);
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1079
|
+
$mol_assert_like('#2#'.match(year), null);
|
|
1080
|
+
$mol_assert_like('#20#'.match(year), ['20']);
|
|
1081
|
+
$mol_assert_like('#2020#'.match(year), ['2020']);
|
|
1082
|
+
$mol_assert_like('#20201#'.match(year), ['2020']);
|
|
1077
1083
|
},
|
|
1078
1084
|
'repeat from'() {
|
|
1079
|
-
const { repeat_greedy, latin_only: letter } =
|
|
1085
|
+
const { repeat_greedy, latin_only: letter } = $mol_regexp;
|
|
1080
1086
|
const name = repeat_greedy(letter, 2);
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1087
|
+
$mol_assert_like('##'.match(name), null);
|
|
1088
|
+
$mol_assert_like('#a#'.match(name), null);
|
|
1089
|
+
$mol_assert_like('#ab#'.match(name), ['ab']);
|
|
1090
|
+
$mol_assert_like('#abc#'.match(name), ['abc']);
|
|
1085
1091
|
},
|
|
1086
1092
|
'from string'() {
|
|
1087
|
-
const regexp =
|
|
1088
|
-
|
|
1089
|
-
|
|
1093
|
+
const regexp = $mol_regexp.from('[\\d]');
|
|
1094
|
+
$mol_assert_equal(regexp.source, '\\[\\\\d\\]');
|
|
1095
|
+
$mol_assert_equal(regexp.flags, 'gsu');
|
|
1090
1096
|
},
|
|
1091
1097
|
'from regexp'() {
|
|
1092
|
-
const regexp =
|
|
1093
|
-
|
|
1094
|
-
|
|
1098
|
+
const regexp = $mol_regexp.from(/[\d]/i);
|
|
1099
|
+
$mol_assert_equal(regexp.source, '[\\d]');
|
|
1100
|
+
$mol_assert_equal(regexp.flags, 'i');
|
|
1095
1101
|
},
|
|
1096
1102
|
'split'() {
|
|
1097
|
-
const regexp =
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1103
|
+
const regexp = $mol_regexp.from(';');
|
|
1104
|
+
$mol_assert_like('aaa;bbb;ccc'.split(regexp), ['aaa', ';', 'bbb', ';', 'ccc']);
|
|
1105
|
+
$mol_assert_like('aaa;;ccc'.split(regexp), ['aaa', ';', '', ';', 'ccc']);
|
|
1106
|
+
$mol_assert_like('aaa'.split(regexp), ['aaa']);
|
|
1107
|
+
$mol_assert_like(''.split(regexp), ['']);
|
|
1102
1108
|
},
|
|
1103
1109
|
'test for matching'() {
|
|
1104
|
-
const regexp =
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
+
const regexp = $mol_regexp.from('foo');
|
|
1111
|
+
$mol_assert_like(regexp.test(''), false);
|
|
1112
|
+
$mol_assert_like(regexp.test('fo'), false);
|
|
1113
|
+
$mol_assert_like(regexp.test('foo'), true);
|
|
1114
|
+
$mol_assert_like(regexp.test('foobar'), true);
|
|
1115
|
+
$mol_assert_like(regexp.test('barfoo'), true);
|
|
1110
1116
|
},
|
|
1111
1117
|
'case ignoring'() {
|
|
1112
|
-
const xxx =
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1118
|
+
const xxx = $mol_regexp.from('x', { ignoreCase: true });
|
|
1119
|
+
$mol_assert_like(xxx.flags, 'gisu');
|
|
1120
|
+
$mol_assert_like(xxx.exec('xx')[0], 'x');
|
|
1121
|
+
$mol_assert_like(xxx.exec('XX')[0], 'X');
|
|
1116
1122
|
},
|
|
1117
1123
|
'multiline mode'() {
|
|
1118
|
-
const { end, from } =
|
|
1124
|
+
const { end, from } = $mol_regexp;
|
|
1119
1125
|
const xxx = from(['x', end], { multiline: true });
|
|
1120
|
-
|
|
1121
|
-
|
|
1126
|
+
$mol_assert_like(xxx.exec('x\ny')[0], 'x');
|
|
1127
|
+
$mol_assert_like(xxx.flags, 'gmsu');
|
|
1122
1128
|
},
|
|
1123
1129
|
'flags override'() {
|
|
1124
|
-
const triplet =
|
|
1125
|
-
|
|
1130
|
+
const triplet = $mol_regexp.from($mol_regexp.from(/.../, { ignoreCase: true }), { multiline: true });
|
|
1131
|
+
$mol_assert_like(triplet.toString(), '/.../gmsu');
|
|
1126
1132
|
},
|
|
1127
1133
|
'sequence'() {
|
|
1128
|
-
const { begin, end, decimal_only: digit, repeat, from } =
|
|
1134
|
+
const { begin, end, decimal_only: digit, repeat, from } = $mol_regexp;
|
|
1129
1135
|
const year = repeat(digit, 4, 4);
|
|
1130
1136
|
const dash = '-';
|
|
1131
1137
|
const month = repeat(digit, 2, 2);
|
|
1132
1138
|
const day = repeat(digit, 2, 2);
|
|
1133
1139
|
const date = from([begin, year, dash, month, dash, day, end]);
|
|
1134
|
-
|
|
1140
|
+
$mol_assert_like(date.exec('2020-01-02')[0], '2020-01-02');
|
|
1135
1141
|
},
|
|
1136
1142
|
'optional'() {
|
|
1137
|
-
const name =
|
|
1138
|
-
|
|
1139
|
-
|
|
1143
|
+
const name = $mol_regexp.from(['A', ['4']]);
|
|
1144
|
+
$mol_assert_equal('AB'.match(name)[0], 'A');
|
|
1145
|
+
$mol_assert_equal('A4'.match(name)[0], 'A4');
|
|
1140
1146
|
},
|
|
1141
1147
|
'only groups'() {
|
|
1142
|
-
const regexp =
|
|
1143
|
-
|
|
1144
|
-
|
|
1148
|
+
const regexp = $mol_regexp.from({ dog: '@' });
|
|
1149
|
+
$mol_assert_like([...'#'.matchAll(regexp)][0].groups, undefined);
|
|
1150
|
+
$mol_assert_like([...'@'.matchAll(regexp)][0].groups, { dog: '@' });
|
|
1145
1151
|
},
|
|
1146
1152
|
'catch skipped'() {
|
|
1147
|
-
const regexp =
|
|
1148
|
-
|
|
1153
|
+
const regexp = $mol_regexp.from(/(@)(\d?)/g);
|
|
1154
|
+
$mol_assert_like([...'[[@]]'.matchAll(regexp)].map(f => [...f]), [
|
|
1149
1155
|
['[['],
|
|
1150
1156
|
['@', '@', ''],
|
|
1151
1157
|
[']]'],
|
|
@@ -1157,11 +1163,11 @@ var $;
|
|
|
1157
1163
|
Sex["male"] = "male";
|
|
1158
1164
|
Sex["female"] = "female";
|
|
1159
1165
|
})(Sex || (Sex = {}));
|
|
1160
|
-
const sexism =
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1166
|
+
const sexism = $mol_regexp.from(Sex);
|
|
1167
|
+
$mol_assert_like([...''.matchAll(sexism)].length, 0);
|
|
1168
|
+
$mol_assert_like([...'trans'.matchAll(sexism)][0].groups, undefined);
|
|
1169
|
+
$mol_assert_like([...'male'.matchAll(sexism)][0].groups, { male: 'male', female: '' });
|
|
1170
|
+
$mol_assert_like([...'female'.matchAll(sexism)][0].groups, { male: '', female: 'female' });
|
|
1165
1171
|
},
|
|
1166
1172
|
'recursive only groups'() {
|
|
1167
1173
|
let Sex;
|
|
@@ -1169,20 +1175,20 @@ var $;
|
|
|
1169
1175
|
Sex["male"] = "male";
|
|
1170
1176
|
Sex["female"] = "female";
|
|
1171
1177
|
})(Sex || (Sex = {}));
|
|
1172
|
-
const sexism =
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1178
|
+
const sexism = $mol_regexp.from({ Sex });
|
|
1179
|
+
$mol_assert_like([...''.matchAll(sexism)].length, 0);
|
|
1180
|
+
$mol_assert_like([...'male'.matchAll(sexism)][0].groups, { Sex: 'male', male: 'male', female: '' });
|
|
1181
|
+
$mol_assert_like([...'female'.matchAll(sexism)][0].groups, { Sex: 'female', male: '', female: 'female' });
|
|
1176
1182
|
},
|
|
1177
1183
|
'sequence with groups'() {
|
|
1178
|
-
const { begin, end, decimal_only: digit, repeat, from } =
|
|
1184
|
+
const { begin, end, decimal_only: digit, repeat, from } = $mol_regexp;
|
|
1179
1185
|
const year = repeat(digit, 4, 4);
|
|
1180
1186
|
const dash = '-';
|
|
1181
1187
|
const month = repeat(digit, 2, 2);
|
|
1182
1188
|
const day = repeat(digit, 2, 2);
|
|
1183
1189
|
const regexp = from([begin, { year }, dash, { month }, dash, { day }, end]);
|
|
1184
1190
|
const found = [...'2020-01-02'.matchAll(regexp)];
|
|
1185
|
-
|
|
1191
|
+
$mol_assert_like(found[0].groups, {
|
|
1186
1192
|
year: '2020',
|
|
1187
1193
|
month: '01',
|
|
1188
1194
|
day: '02',
|
|
@@ -1191,8 +1197,8 @@ var $;
|
|
|
1191
1197
|
'sequence with groups of mixed type'() {
|
|
1192
1198
|
const prefix = '/';
|
|
1193
1199
|
const postfix = '/';
|
|
1194
|
-
const regexp =
|
|
1195
|
-
|
|
1200
|
+
const regexp = $mol_regexp.from([{ prefix }, /(\w+)/, { postfix }, /([gumi]*)/]);
|
|
1201
|
+
$mol_assert_like([...'/foo/mi'.matchAll(regexp)], [
|
|
1196
1202
|
Object.assign(["/foo/mi", "/", "foo", "/", "mi"], {
|
|
1197
1203
|
groups: {
|
|
1198
1204
|
prefix: '/',
|
|
@@ -1204,7 +1210,7 @@ var $;
|
|
|
1204
1210
|
]);
|
|
1205
1211
|
},
|
|
1206
1212
|
'recursive sequence with groups'() {
|
|
1207
|
-
const { begin, end, decimal_only: digit, repeat, from } =
|
|
1213
|
+
const { begin, end, decimal_only: digit, repeat, from } = $mol_regexp;
|
|
1208
1214
|
const year = repeat(digit, 4, 4);
|
|
1209
1215
|
const dash = '-';
|
|
1210
1216
|
const month = repeat(digit, 2, 2);
|
|
@@ -1213,7 +1219,7 @@ var $;
|
|
|
1213
1219
|
begin, { date: [{ year }, dash, { month }] }, dash, { day }, end
|
|
1214
1220
|
]);
|
|
1215
1221
|
const found = [...'2020-01-02'.matchAll(regexp)];
|
|
1216
|
-
|
|
1222
|
+
$mol_assert_like(found[0].groups, {
|
|
1217
1223
|
date: '2020-01',
|
|
1218
1224
|
year: '2020',
|
|
1219
1225
|
month: '01',
|
|
@@ -1221,70 +1227,70 @@ var $;
|
|
|
1221
1227
|
});
|
|
1222
1228
|
},
|
|
1223
1229
|
'parse multiple'() {
|
|
1224
|
-
const { decimal_only: digit, from } =
|
|
1230
|
+
const { decimal_only: digit, from } = $mol_regexp;
|
|
1225
1231
|
const regexp = from({ digit });
|
|
1226
|
-
|
|
1232
|
+
$mol_assert_like([...'123'.matchAll(regexp)].map(f => f.groups), [
|
|
1227
1233
|
{ digit: '1' },
|
|
1228
1234
|
{ digit: '2' },
|
|
1229
1235
|
{ digit: '3' },
|
|
1230
1236
|
]);
|
|
1231
1237
|
},
|
|
1232
1238
|
'variants'() {
|
|
1233
|
-
const { begin, or, end, from } =
|
|
1239
|
+
const { begin, or, end, from } = $mol_regexp;
|
|
1234
1240
|
const sexism = from([
|
|
1235
1241
|
begin, 'sex = ', { sex: ['male', or, 'female'] }, end
|
|
1236
1242
|
]);
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1243
|
+
$mol_assert_like([...'sex = male'.matchAll(sexism)][0].groups, { sex: 'male' });
|
|
1244
|
+
$mol_assert_like([...'sex = female'.matchAll(sexism)][0].groups, { sex: 'female' });
|
|
1245
|
+
$mol_assert_like([...'sex = malefemale'.matchAll(sexism)][0].groups, undefined);
|
|
1240
1246
|
},
|
|
1241
1247
|
'force after'() {
|
|
1242
|
-
const { latin_only: letter, force_after, from } =
|
|
1248
|
+
const { latin_only: letter, force_after, from } = $mol_regexp;
|
|
1243
1249
|
const regexp = from([letter, force_after('.')]);
|
|
1244
|
-
|
|
1245
|
-
|
|
1250
|
+
$mol_assert_like('x.'.match(regexp), ['x']);
|
|
1251
|
+
$mol_assert_like('x,'.match(regexp), null);
|
|
1246
1252
|
},
|
|
1247
1253
|
'forbid after'() {
|
|
1248
|
-
const { latin_only: letter, forbid_after, from } =
|
|
1254
|
+
const { latin_only: letter, forbid_after, from } = $mol_regexp;
|
|
1249
1255
|
const regexp = from([letter, forbid_after('.')]);
|
|
1250
|
-
|
|
1251
|
-
|
|
1256
|
+
$mol_assert_like('x.'.match(regexp), null);
|
|
1257
|
+
$mol_assert_like('x,'.match(regexp), ['x']);
|
|
1252
1258
|
},
|
|
1253
1259
|
'char except'() {
|
|
1254
|
-
const { char_except, latin_only, tab } =
|
|
1260
|
+
const { char_except, latin_only, tab } = $mol_regexp;
|
|
1255
1261
|
const name = char_except(latin_only, tab);
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1262
|
+
$mol_assert_like('a'.match(name), null);
|
|
1263
|
+
$mol_assert_like('\t'.match(name), null);
|
|
1264
|
+
$mol_assert_like('('.match(name), ['(']);
|
|
1259
1265
|
},
|
|
1260
1266
|
'unicode only'() {
|
|
1261
|
-
const { unicode_only, from } =
|
|
1267
|
+
const { unicode_only, from } = $mol_regexp;
|
|
1262
1268
|
const name = from([
|
|
1263
1269
|
unicode_only('Script', 'Cyrillic'),
|
|
1264
1270
|
unicode_only('Hex_Digit'),
|
|
1265
1271
|
]);
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1272
|
+
$mol_assert_like('FF'.match(name), null);
|
|
1273
|
+
$mol_assert_like('ФG'.match(name), null);
|
|
1274
|
+
$mol_assert_like('ФF'.match(name), ['ФF']);
|
|
1269
1275
|
},
|
|
1270
1276
|
'generate by optional with inner group'() {
|
|
1271
|
-
const { begin, end, from } =
|
|
1277
|
+
const { begin, end, from } = $mol_regexp;
|
|
1272
1278
|
const animals = from([begin, '#', ['^', { dog: '@' }], end]);
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1279
|
+
$mol_assert_equal(animals.generate({}), '#');
|
|
1280
|
+
$mol_assert_equal(animals.generate({ dog: false }), '#');
|
|
1281
|
+
$mol_assert_equal(animals.generate({ dog: true }), '#^@');
|
|
1282
|
+
$mol_assert_fail(() => animals.generate({ dog: '$' }), 'Wrong param: dog=$');
|
|
1277
1283
|
},
|
|
1278
1284
|
'generate by optional with inner group with variants'() {
|
|
1279
|
-
const { begin, end, from } =
|
|
1285
|
+
const { begin, end, from } = $mol_regexp;
|
|
1280
1286
|
const animals = from([begin, '#', ['^', { animal: { dog: '@', fox: '&' } }], end]);
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1287
|
+
$mol_assert_equal(animals.generate({}), '#');
|
|
1288
|
+
$mol_assert_equal(animals.generate({ dog: true }), '#^@');
|
|
1289
|
+
$mol_assert_equal(animals.generate({ fox: true }), '#^&');
|
|
1290
|
+
$mol_assert_fail(() => animals.generate({ dog: '$' }), 'Wrong param: dog=$');
|
|
1285
1291
|
},
|
|
1286
1292
|
'complex example'() {
|
|
1287
|
-
const { begin, end, char_only, char_range, latin_only, slash_back, repeat_greedy, from, } =
|
|
1293
|
+
const { begin, end, char_only, char_range, latin_only, slash_back, repeat_greedy, from, } = $mol_regexp;
|
|
1288
1294
|
const atom_char = char_only(latin_only, "!#$%&'*+/=?^`{|}~-");
|
|
1289
1295
|
const atom = repeat_greedy(atom_char, 1);
|
|
1290
1296
|
const dot_atom = from([atom, repeat_greedy(['.', atom])]);
|
|
@@ -1298,9 +1304,9 @@ var $;
|
|
|
1298
1304
|
const local_part = from({ dot_atom, quoted_name });
|
|
1299
1305
|
const domain = dot_atom;
|
|
1300
1306
|
const mail = from([begin, local_part, '@', { domain }, end]);
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1307
|
+
$mol_assert_equal('foo..bar@example.org'.match(mail), null);
|
|
1308
|
+
$mol_assert_equal('foo..bar"@example.org'.match(mail), null);
|
|
1309
|
+
$mol_assert_like([...'foo.bar@example.org'.matchAll(mail)][0].groups, {
|
|
1304
1310
|
domain: "example.org",
|
|
1305
1311
|
dot_atom: "foo.bar",
|
|
1306
1312
|
name: "",
|
|
@@ -1308,7 +1314,7 @@ var $;
|
|
|
1308
1314
|
quoted_name: "",
|
|
1309
1315
|
quoted_pair: "",
|
|
1310
1316
|
});
|
|
1311
|
-
|
|
1317
|
+
$mol_assert_like([...'"foo..bar"@example.org'.matchAll(mail)][0].groups, {
|
|
1312
1318
|
dot_atom: "",
|
|
1313
1319
|
quoted_name: '"foo..bar"',
|
|
1314
1320
|
name: "foo..bar",
|
|
@@ -1316,13 +1322,13 @@ var $;
|
|
|
1316
1322
|
quoted_pair: "",
|
|
1317
1323
|
domain: "example.org",
|
|
1318
1324
|
});
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1325
|
+
$mol_assert_equal(mail.generate({ dot_atom: 'foo.bar', domain: 'example.org' }), 'foo.bar@example.org');
|
|
1326
|
+
$mol_assert_equal(mail.generate({ name: 'foo..bar', domain: 'example.org' }), '"foo..bar"@example.org');
|
|
1327
|
+
$mol_assert_fail(() => mail.generate({ dot_atom: 'foo..bar', domain: 'example.org' }), 'Wrong param: dot_atom=foo..bar');
|
|
1322
1328
|
},
|
|
1323
1329
|
});
|
|
1324
1330
|
})($ || ($ = {}));
|
|
1325
|
-
//regexp.test.
|
|
1331
|
+
//mol/regexp/regexp.test.ts
|
|
1326
1332
|
;
|
|
1327
1333
|
"use strict";
|
|
1328
1334
|
var $;
|
|
@@ -1346,7 +1352,7 @@ var $;
|
|
|
1346
1352
|
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
1347
1353
|
$.$mol_log3_stack = [];
|
|
1348
1354
|
})($ || ($ = {}));
|
|
1349
|
-
//log3.
|
|
1355
|
+
//mol/log3/log3.ts
|
|
1350
1356
|
;
|
|
1351
1357
|
"use strict";
|
|
1352
1358
|
var $;
|
|
@@ -1374,12 +1380,12 @@ var $;
|
|
|
1374
1380
|
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', 'magenta');
|
|
1375
1381
|
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', 'cyan');
|
|
1376
1382
|
})($ || ($ = {}));
|
|
1377
|
-
//log3.node.
|
|
1383
|
+
//mol/log3/log3.node.ts
|
|
1378
1384
|
;
|
|
1379
1385
|
"use strict";
|
|
1380
1386
|
var $;
|
|
1381
1387
|
(function ($_1) {
|
|
1382
|
-
$
|
|
1388
|
+
$mol_test_mocks.push($ => {
|
|
1383
1389
|
$.$mol_log3_come = () => { };
|
|
1384
1390
|
$.$mol_log3_done = () => { };
|
|
1385
1391
|
$.$mol_log3_fail = () => { };
|
|
@@ -1388,7 +1394,7 @@ var $;
|
|
|
1388
1394
|
$.$mol_log3_area = () => () => { };
|
|
1389
1395
|
});
|
|
1390
1396
|
})($ || ($ = {}));
|
|
1391
|
-
//log3.test.
|
|
1397
|
+
//mol/log3/log3.test.ts
|
|
1392
1398
|
;
|
|
1393
1399
|
"use strict";
|
|
1394
1400
|
var $;
|
|
@@ -1398,7 +1404,7 @@ var $;
|
|
|
1398
1404
|
}
|
|
1399
1405
|
$.$mol_env = $mol_env;
|
|
1400
1406
|
})($ || ($ = {}));
|
|
1401
|
-
//env.
|
|
1407
|
+
//mol/env/env.ts
|
|
1402
1408
|
;
|
|
1403
1409
|
"use strict";
|
|
1404
1410
|
var $;
|
|
@@ -1407,7 +1413,7 @@ var $;
|
|
|
1407
1413
|
return this.process.env;
|
|
1408
1414
|
};
|
|
1409
1415
|
})($ || ($ = {}));
|
|
1410
|
-
//env.node.
|
|
1416
|
+
//mol/env/env.node.ts
|
|
1411
1417
|
;
|
|
1412
1418
|
"use strict";
|
|
1413
1419
|
var $;
|
|
@@ -1427,14 +1433,14 @@ var $;
|
|
|
1427
1433
|
env: this.$mol_env(),
|
|
1428
1434
|
});
|
|
1429
1435
|
if (res.status || res.error)
|
|
1430
|
-
return
|
|
1436
|
+
return $mol_fail(res.error || new Error(res.stderr.toString()));
|
|
1431
1437
|
if (!res.stdout)
|
|
1432
1438
|
res.stdout = Buffer.from([]);
|
|
1433
1439
|
return res;
|
|
1434
1440
|
}
|
|
1435
1441
|
$.$mol_exec = $mol_exec;
|
|
1436
1442
|
})($ || ($ = {}));
|
|
1437
|
-
//exec.node.
|
|
1443
|
+
//mol/exec/exec.node.ts
|
|
1438
1444
|
;
|
|
1439
1445
|
"use strict";
|
|
1440
1446
|
var $;
|
|
@@ -1445,29 +1451,29 @@ var $;
|
|
|
1445
1451
|
}
|
|
1446
1452
|
$.$mol_ambient = $mol_ambient;
|
|
1447
1453
|
})($ || ($ = {}));
|
|
1448
|
-
//ambient.
|
|
1454
|
+
//mol/ambient/ambient.ts
|
|
1449
1455
|
;
|
|
1450
1456
|
"use strict";
|
|
1451
1457
|
var $;
|
|
1452
1458
|
(function ($) {
|
|
1453
|
-
|
|
1459
|
+
$mol_test({
|
|
1454
1460
|
'get'() {
|
|
1455
|
-
const proxy =
|
|
1456
|
-
|
|
1461
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1462
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
1457
1463
|
},
|
|
1458
1464
|
'has'() {
|
|
1459
|
-
const proxy =
|
|
1460
|
-
|
|
1465
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1466
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
1461
1467
|
},
|
|
1462
1468
|
'set'() {
|
|
1463
1469
|
const target = { foo: 777 };
|
|
1464
|
-
const proxy =
|
|
1470
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1465
1471
|
proxy.foo = 123;
|
|
1466
|
-
|
|
1472
|
+
$mol_assert_equal(target.foo, 123);
|
|
1467
1473
|
},
|
|
1468
1474
|
'getOwnPropertyDescriptor'() {
|
|
1469
|
-
const proxy =
|
|
1470
|
-
|
|
1475
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1476
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1471
1477
|
value: 777,
|
|
1472
1478
|
writable: true,
|
|
1473
1479
|
enumerable: true,
|
|
@@ -1475,40 +1481,40 @@ var $;
|
|
|
1475
1481
|
});
|
|
1476
1482
|
},
|
|
1477
1483
|
'ownKeys'() {
|
|
1478
|
-
const proxy =
|
|
1479
|
-
|
|
1484
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
1485
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1480
1486
|
},
|
|
1481
1487
|
'getPrototypeOf'() {
|
|
1482
1488
|
class Foo {
|
|
1483
1489
|
}
|
|
1484
|
-
const proxy =
|
|
1485
|
-
|
|
1490
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1491
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1486
1492
|
},
|
|
1487
1493
|
'setPrototypeOf'() {
|
|
1488
1494
|
class Foo {
|
|
1489
1495
|
}
|
|
1490
1496
|
const target = {};
|
|
1491
|
-
const proxy =
|
|
1497
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1492
1498
|
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
1493
|
-
|
|
1499
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
1494
1500
|
},
|
|
1495
1501
|
'instanceof'() {
|
|
1496
1502
|
class Foo {
|
|
1497
1503
|
}
|
|
1498
|
-
const proxy =
|
|
1499
|
-
|
|
1500
|
-
|
|
1504
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1505
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1506
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1501
1507
|
},
|
|
1502
1508
|
'autobind'() {
|
|
1503
1509
|
class Foo {
|
|
1504
1510
|
}
|
|
1505
|
-
const proxy =
|
|
1506
|
-
|
|
1507
|
-
|
|
1511
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1512
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1513
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1508
1514
|
},
|
|
1509
1515
|
});
|
|
1510
1516
|
})($ || ($ = {}));
|
|
1511
|
-
//delegate.test.
|
|
1517
|
+
//mol/delegate/delegate.test.ts
|
|
1512
1518
|
;
|
|
1513
1519
|
"use strict";
|
|
1514
1520
|
var $;
|
|
@@ -1545,7 +1551,7 @@ var $;
|
|
|
1545
1551
|
value: (obj) => instances.has(obj),
|
|
1546
1552
|
});
|
|
1547
1553
|
})($ || ($ = {}));
|
|
1548
|
-
//delegate.
|
|
1554
|
+
//mol/delegate/delegate.ts
|
|
1549
1555
|
;
|
|
1550
1556
|
"use strict";
|
|
1551
1557
|
var $;
|
|
@@ -1557,7 +1563,7 @@ var $;
|
|
|
1557
1563
|
return false;
|
|
1558
1564
|
if (typeof having !== 'object')
|
|
1559
1565
|
return false;
|
|
1560
|
-
if (having instanceof
|
|
1566
|
+
if (having instanceof $mol_delegate)
|
|
1561
1567
|
return false;
|
|
1562
1568
|
if (typeof having['destructor'] !== 'function')
|
|
1563
1569
|
return false;
|
|
@@ -1601,30 +1607,30 @@ var $;
|
|
|
1601
1607
|
}
|
|
1602
1608
|
$.$mol_owning_catch = $mol_owning_catch;
|
|
1603
1609
|
})($ || ($ = {}));
|
|
1604
|
-
//owning.
|
|
1610
|
+
//mol/owning/owning.ts
|
|
1605
1611
|
;
|
|
1606
1612
|
"use strict";
|
|
1607
|
-
//writable.test.
|
|
1613
|
+
//mol/type/writable/writable.test.ts
|
|
1608
1614
|
;
|
|
1609
1615
|
"use strict";
|
|
1610
|
-
//writable.
|
|
1616
|
+
//mol/type/writable/writable.ts
|
|
1611
1617
|
;
|
|
1612
1618
|
"use strict";
|
|
1613
1619
|
var $;
|
|
1614
1620
|
(function ($) {
|
|
1615
1621
|
class $mol_object2 {
|
|
1616
1622
|
static $ = $;
|
|
1617
|
-
[
|
|
1623
|
+
[$mol_ambient_ref] = null;
|
|
1618
1624
|
get $() {
|
|
1619
|
-
if (this[
|
|
1620
|
-
return this[
|
|
1621
|
-
const owner =
|
|
1622
|
-
return this[
|
|
1625
|
+
if (this[$mol_ambient_ref])
|
|
1626
|
+
return this[$mol_ambient_ref];
|
|
1627
|
+
const owner = $mol_owning_get(this);
|
|
1628
|
+
return this[$mol_ambient_ref] = owner?.$ || $mol_object2.$;
|
|
1623
1629
|
}
|
|
1624
1630
|
set $(next) {
|
|
1625
|
-
if (this[
|
|
1626
|
-
|
|
1627
|
-
this[
|
|
1631
|
+
if (this[$mol_ambient_ref])
|
|
1632
|
+
$mol_fail_hidden(new Error('Context already defined'));
|
|
1633
|
+
this[$mol_ambient_ref] = next;
|
|
1628
1634
|
}
|
|
1629
1635
|
static create(init) {
|
|
1630
1636
|
const obj = new this;
|
|
@@ -1650,7 +1656,7 @@ var $;
|
|
|
1650
1656
|
}
|
|
1651
1657
|
$.$mol_object2 = $mol_object2;
|
|
1652
1658
|
})($ || ($ = {}));
|
|
1653
|
-
//object2.
|
|
1659
|
+
//mol/object2/object2.ts
|
|
1654
1660
|
;
|
|
1655
1661
|
"use strict";
|
|
1656
1662
|
var $;
|
|
@@ -1661,7 +1667,7 @@ var $;
|
|
|
1661
1667
|
let warned = false;
|
|
1662
1668
|
descr.value = function $mol_deprecated_wrapper(...args) {
|
|
1663
1669
|
if (!warned) {
|
|
1664
|
-
|
|
1670
|
+
$$.$mol_log3_warn({
|
|
1665
1671
|
place: `${host.constructor.name}::${field}`,
|
|
1666
1672
|
message: `Deprecated`,
|
|
1667
1673
|
hint: message,
|
|
@@ -1674,54 +1680,54 @@ var $;
|
|
|
1674
1680
|
}
|
|
1675
1681
|
$.$mol_deprecated = $mol_deprecated;
|
|
1676
1682
|
})($ || ($ = {}));
|
|
1677
|
-
//deprecated.
|
|
1683
|
+
//mol/deprecated/deprecated.ts
|
|
1678
1684
|
;
|
|
1679
1685
|
"use strict";
|
|
1680
1686
|
var $;
|
|
1681
1687
|
(function ($_1) {
|
|
1682
|
-
$
|
|
1688
|
+
$mol_test({
|
|
1683
1689
|
'tree parsing'() {
|
|
1684
|
-
$
|
|
1685
|
-
$
|
|
1686
|
-
$
|
|
1687
|
-
$
|
|
1688
|
-
$
|
|
1689
|
-
$
|
|
1690
|
-
$
|
|
1691
|
-
$
|
|
1690
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
1691
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
1692
|
+
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
1693
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
1694
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
1695
|
+
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
1696
|
+
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
1697
|
+
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
1692
1698
|
},
|
|
1693
1699
|
'inserting'() {
|
|
1694
|
-
$
|
|
1695
|
-
$
|
|
1696
|
-
$
|
|
1697
|
-
$
|
|
1698
|
-
$
|
|
1699
|
-
$
|
|
1700
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
1701
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
1702
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
1703
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
1704
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
1705
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
1700
1706
|
},
|
|
1701
1707
|
'fromJSON'() {
|
|
1702
|
-
$
|
|
1703
|
-
$
|
|
1704
|
-
$
|
|
1705
|
-
$
|
|
1706
|
-
$
|
|
1708
|
+
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
1709
|
+
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
1710
|
+
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
1711
|
+
$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');
|
|
1712
|
+
$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');
|
|
1707
1713
|
},
|
|
1708
1714
|
'toJSON'() {
|
|
1709
|
-
$
|
|
1710
|
-
$
|
|
1711
|
-
$
|
|
1712
|
-
$
|
|
1713
|
-
$
|
|
1715
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
1716
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
1717
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
1718
|
+
$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"]');
|
|
1719
|
+
$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"}');
|
|
1714
1720
|
},
|
|
1715
1721
|
'hack'() {
|
|
1716
|
-
const res = $
|
|
1722
|
+
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
1717
1723
|
'': (tree, context) => [tree.hack(context)],
|
|
1718
1724
|
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
1719
1725
|
});
|
|
1720
|
-
$
|
|
1726
|
+
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
1721
1727
|
},
|
|
1722
1728
|
'errors handling'($) {
|
|
1723
1729
|
const errors = [];
|
|
1724
|
-
class Tree extends $
|
|
1730
|
+
class Tree extends $mol_tree {
|
|
1725
1731
|
static $ = $.$mol_ambient({
|
|
1726
1732
|
$mol_fail: error => errors.push(error.message)
|
|
1727
1733
|
});
|
|
@@ -1730,17 +1736,17 @@ var $;
|
|
|
1730
1736
|
\t \tfoo
|
|
1731
1737
|
bar \\data
|
|
1732
1738
|
`, 'test');
|
|
1733
|
-
$
|
|
1739
|
+
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
1734
1740
|
},
|
|
1735
1741
|
});
|
|
1736
1742
|
})($ || ($ = {}));
|
|
1737
|
-
//tree.test.
|
|
1743
|
+
//mol/tree/tree.test.ts
|
|
1738
1744
|
;
|
|
1739
1745
|
"use strict";
|
|
1740
1746
|
var $;
|
|
1741
1747
|
(function ($) {
|
|
1742
1748
|
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
1743
|
-
class $mol_tree extends
|
|
1749
|
+
class $mol_tree extends $mol_object2 {
|
|
1744
1750
|
type;
|
|
1745
1751
|
data;
|
|
1746
1752
|
sub;
|
|
@@ -2053,7 +2059,7 @@ var $;
|
|
|
2053
2059
|
const sub = [].concat(...this.sub.map(child => {
|
|
2054
2060
|
const handle = context[child.type] || context[''];
|
|
2055
2061
|
if (!handle)
|
|
2056
|
-
|
|
2062
|
+
$mol_fail(child.error('Handler not defined'));
|
|
2057
2063
|
return handle(child, context);
|
|
2058
2064
|
}));
|
|
2059
2065
|
return this.clone({ sub });
|
|
@@ -2063,10 +2069,10 @@ var $;
|
|
|
2063
2069
|
}
|
|
2064
2070
|
}
|
|
2065
2071
|
__decorate([
|
|
2066
|
-
|
|
2072
|
+
$mol_deprecated('Use $mol_tree:hack')
|
|
2067
2073
|
], $mol_tree.prototype, "transform", null);
|
|
2068
2074
|
$.$mol_tree = $mol_tree;
|
|
2069
2075
|
})($ || ($ = {}));
|
|
2070
|
-
//tree.
|
|
2076
|
+
//mol/tree/tree.ts
|
|
2071
2077
|
|
|
2072
2078
|
//# sourceMappingURL=node.test.js.map
|