mol_mutable 0.0.49 → 0.0.51
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 +13 -13
- package/node.js.map +1 -1
- package/node.mjs +13 -13
- package/node.mjs.map +1 -1
- package/node.test.js +286 -286
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.deps.json +1 -1
- package/web.js +13 -13
- package/web.js.map +1 -1
- package/web.mjs +13 -13
- package/web.mjs.map +1 -1
- package/web.test.js +181 -181
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
"use strict";
|
|
3
|
+
Error.stackTraceLimit = 50;
|
|
4
|
+
var $;
|
|
5
|
+
(function ($) {
|
|
6
|
+
})($ || ($ = {}));
|
|
7
|
+
module.exports = $;
|
|
8
|
+
//mam.ts
|
|
9
|
+
;
|
|
2
10
|
"use strict"
|
|
3
11
|
|
|
4
12
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
@@ -11,14 +19,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
11
19
|
var $ = ( typeof module === 'object' ) ? ( module['export'+'s'] = globalThis ) : globalThis
|
|
12
20
|
$.$$ = $
|
|
13
21
|
|
|
14
|
-
;
|
|
15
|
-
"use strict";
|
|
16
|
-
Error.stackTraceLimit = 50;
|
|
17
|
-
var $;
|
|
18
|
-
(function ($) {
|
|
19
|
-
})($ || ($ = {}));
|
|
20
|
-
module.exports = $;
|
|
21
|
-
//mam.ts
|
|
22
22
|
;
|
|
23
23
|
"use strict";
|
|
24
24
|
//mol/type/immutable/deep/deep/deep.ts
|
|
@@ -85,16 +85,6 @@ var $;
|
|
|
85
85
|
;
|
|
86
86
|
"use strict";
|
|
87
87
|
var $;
|
|
88
|
-
(function ($) {
|
|
89
|
-
function $mol_test_complete() {
|
|
90
|
-
process.exit(0);
|
|
91
|
-
}
|
|
92
|
-
$.$mol_test_complete = $mol_test_complete;
|
|
93
|
-
})($ || ($ = {}));
|
|
94
|
-
//mol/test/test.node.test.ts
|
|
95
|
-
;
|
|
96
|
-
"use strict";
|
|
97
|
-
var $;
|
|
98
88
|
(function ($_1) {
|
|
99
89
|
function $mol_test(set) {
|
|
100
90
|
for (let name in set) {
|
|
@@ -182,6 +172,16 @@ var $;
|
|
|
182
172
|
;
|
|
183
173
|
"use strict";
|
|
184
174
|
var $;
|
|
175
|
+
(function ($) {
|
|
176
|
+
function $mol_test_complete() {
|
|
177
|
+
process.exit(0);
|
|
178
|
+
}
|
|
179
|
+
$.$mol_test_complete = $mol_test_complete;
|
|
180
|
+
})($ || ($ = {}));
|
|
181
|
+
//mol/test/test.node.test.ts
|
|
182
|
+
;
|
|
183
|
+
"use strict";
|
|
184
|
+
var $;
|
|
185
185
|
(function ($) {
|
|
186
186
|
})($ || ($ = {}));
|
|
187
187
|
//mol/dom/context/context.ts
|
|
@@ -454,96 +454,6 @@ var $;
|
|
|
454
454
|
;
|
|
455
455
|
"use strict";
|
|
456
456
|
var $;
|
|
457
|
-
(function ($) {
|
|
458
|
-
$mol_test({
|
|
459
|
-
'Make empty div'() {
|
|
460
|
-
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
|
461
|
-
},
|
|
462
|
-
'Define native field'() {
|
|
463
|
-
const dom = $mol_jsx("input", { value: '123' });
|
|
464
|
-
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
465
|
-
$mol_assert_equal(dom.value, '123');
|
|
466
|
-
},
|
|
467
|
-
'Define classes'() {
|
|
468
|
-
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
469
|
-
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
470
|
-
},
|
|
471
|
-
'Define styles'() {
|
|
472
|
-
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
473
|
-
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
474
|
-
},
|
|
475
|
-
'Define dataset'() {
|
|
476
|
-
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
477
|
-
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
478
|
-
},
|
|
479
|
-
'Define attributes'() {
|
|
480
|
-
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
481
|
-
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
482
|
-
},
|
|
483
|
-
'Define child nodes'() {
|
|
484
|
-
const dom = $mol_jsx("div", null,
|
|
485
|
-
"hello",
|
|
486
|
-
$mol_jsx("strong", null, "world"),
|
|
487
|
-
"!");
|
|
488
|
-
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
489
|
-
},
|
|
490
|
-
'Function as component'() {
|
|
491
|
-
const Button = (props, target) => {
|
|
492
|
-
return $mol_jsx("button", { title: props.hint }, target());
|
|
493
|
-
};
|
|
494
|
-
const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
|
|
495
|
-
$mol_assert_equal(dom.outerHTML, '<button id="foo" title="click me" class="Button">hey!</button>');
|
|
496
|
-
},
|
|
497
|
-
'Nested guid generation'() {
|
|
498
|
-
const Foo = () => {
|
|
499
|
-
return $mol_jsx("div", null,
|
|
500
|
-
$mol_jsx(Bar, { id: "bar" },
|
|
501
|
-
$mol_jsx("img", { id: "icon" })));
|
|
502
|
-
};
|
|
503
|
-
const Bar = (props, icon) => {
|
|
504
|
-
return $mol_jsx("span", null,
|
|
505
|
-
icon,
|
|
506
|
-
$mol_jsx("i", { id: "label" }));
|
|
507
|
-
};
|
|
508
|
-
const dom = $mol_jsx(Foo, { id: "foo" });
|
|
509
|
-
$mol_assert_equal(dom.outerHTML, '<div id="foo" class="Foo"><span id="foo/bar" class="Foo_bar Bar"><img id="foo/icon" class="Foo_icon"><i id="foo/bar/label" class="Foo_bar_label Bar_label"></i></span></div>');
|
|
510
|
-
},
|
|
511
|
-
'Fail on non unique ids'() {
|
|
512
|
-
const App = () => {
|
|
513
|
-
return $mol_jsx("div", null,
|
|
514
|
-
$mol_jsx("span", { id: "bar" }),
|
|
515
|
-
$mol_jsx("span", { id: "bar" }));
|
|
516
|
-
};
|
|
517
|
-
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
|
518
|
-
},
|
|
519
|
-
'Owner based guid generationn'() {
|
|
520
|
-
const Foo = () => {
|
|
521
|
-
return $mol_jsx("div", null,
|
|
522
|
-
$mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
523
|
-
};
|
|
524
|
-
const Bar = (props) => {
|
|
525
|
-
return $mol_jsx("span", null, props.icon());
|
|
526
|
-
};
|
|
527
|
-
const dom = $mol_jsx(Foo, { id: "app" });
|
|
528
|
-
$mol_assert_equal(dom.outerHTML, '<div id="app" class="Foo"><span id="app/middle" class="Foo_middle Bar"><img id="app/icon" class="Foo_icon"></span></div>');
|
|
529
|
-
},
|
|
530
|
-
'Fail on same ids from different caller'() {
|
|
531
|
-
const Foo = () => {
|
|
532
|
-
return $mol_jsx("div", null,
|
|
533
|
-
$mol_jsx("img", { id: "icon" }),
|
|
534
|
-
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
535
|
-
};
|
|
536
|
-
const Bar = (props) => {
|
|
537
|
-
return $mol_jsx("span", null, props.icon());
|
|
538
|
-
};
|
|
539
|
-
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
|
540
|
-
},
|
|
541
|
-
});
|
|
542
|
-
})($ || ($ = {}));
|
|
543
|
-
//mol/jsx/jsx.test.tsx
|
|
544
|
-
;
|
|
545
|
-
"use strict";
|
|
546
|
-
var $;
|
|
547
457
|
(function ($) {
|
|
548
458
|
$.$mol_jsx_prefix = '';
|
|
549
459
|
$.$mol_jsx_crumbs = '';
|
|
@@ -667,97 +577,91 @@ var $;
|
|
|
667
577
|
var $;
|
|
668
578
|
(function ($) {
|
|
669
579
|
$mol_test({
|
|
670
|
-
'
|
|
671
|
-
$
|
|
672
|
-
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
673
|
-
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
674
|
-
$mol_assert_not($mol_compare_deep({}, null));
|
|
675
|
-
},
|
|
676
|
-
'number'() {
|
|
677
|
-
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
678
|
-
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
679
|
-
$mol_assert_not($mol_compare_deep(1, 2));
|
|
680
|
-
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
681
|
-
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
580
|
+
'Make empty div'() {
|
|
581
|
+
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
|
682
582
|
},
|
|
683
|
-
'
|
|
684
|
-
$
|
|
685
|
-
$
|
|
686
|
-
$
|
|
687
|
-
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
688
|
-
$mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
689
|
-
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
583
|
+
'Define native field'() {
|
|
584
|
+
const dom = $mol_jsx("input", { value: '123' });
|
|
585
|
+
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
586
|
+
$mol_assert_equal(dom.value, '123');
|
|
690
587
|
},
|
|
691
|
-
'
|
|
692
|
-
$
|
|
693
|
-
$
|
|
694
|
-
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
695
|
-
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
588
|
+
'Define classes'() {
|
|
589
|
+
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
590
|
+
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
696
591
|
},
|
|
697
|
-
'
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
701
|
-
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
702
|
-
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
592
|
+
'Define styles'() {
|
|
593
|
+
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
594
|
+
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
703
595
|
},
|
|
704
|
-
'
|
|
705
|
-
const
|
|
706
|
-
|
|
707
|
-
const b = { foo: {} };
|
|
708
|
-
b['self'] = b;
|
|
709
|
-
$mol_assert_ok($mol_compare_deep(a, b));
|
|
596
|
+
'Define dataset'() {
|
|
597
|
+
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
598
|
+
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
710
599
|
},
|
|
711
|
-
'
|
|
712
|
-
$
|
|
713
|
-
$
|
|
600
|
+
'Define attributes'() {
|
|
601
|
+
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
602
|
+
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
714
603
|
},
|
|
715
|
-
'
|
|
716
|
-
$
|
|
717
|
-
|
|
718
|
-
|
|
604
|
+
'Define child nodes'() {
|
|
605
|
+
const dom = $mol_jsx("div", null,
|
|
606
|
+
"hello",
|
|
607
|
+
$mol_jsx("strong", null, "world"),
|
|
608
|
+
"!");
|
|
609
|
+
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
719
610
|
},
|
|
720
|
-
'
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
$
|
|
611
|
+
'Function as component'() {
|
|
612
|
+
const Button = (props, target) => {
|
|
613
|
+
return $mol_jsx("button", { title: props.hint }, target());
|
|
614
|
+
};
|
|
615
|
+
const dom = $mol_jsx(Button, { id: "foo", hint: "click me" }, () => 'hey!');
|
|
616
|
+
$mol_assert_equal(dom.outerHTML, '<button id="foo" title="click me" class="Button">hey!</button>');
|
|
725
617
|
},
|
|
726
|
-
'
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
618
|
+
'Nested guid generation'() {
|
|
619
|
+
const Foo = () => {
|
|
620
|
+
return $mol_jsx("div", null,
|
|
621
|
+
$mol_jsx(Bar, { id: "bar" },
|
|
622
|
+
$mol_jsx("img", { id: "icon" })));
|
|
623
|
+
};
|
|
624
|
+
const Bar = (props, icon) => {
|
|
625
|
+
return $mol_jsx("span", null,
|
|
626
|
+
icon,
|
|
627
|
+
$mol_jsx("i", { id: "label" }));
|
|
628
|
+
};
|
|
629
|
+
const dom = $mol_jsx(Foo, { id: "foo" });
|
|
630
|
+
$mol_assert_equal(dom.outerHTML, '<div id="foo" class="Foo"><span id="foo/bar" class="Foo_bar Bar"><img id="foo/icon" class="Foo_icon"><i id="foo/bar/label" class="Foo_bar_label Bar_label"></i></span></div>');
|
|
732
631
|
},
|
|
733
|
-
'
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
632
|
+
'Fail on non unique ids'() {
|
|
633
|
+
const App = () => {
|
|
634
|
+
return $mol_jsx("div", null,
|
|
635
|
+
$mol_jsx("span", { id: "bar" }),
|
|
636
|
+
$mol_jsx("span", { id: "bar" }));
|
|
637
|
+
};
|
|
638
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "foo" }), 'JSX already has tag with id "foo/bar"');
|
|
737
639
|
},
|
|
738
|
-
'
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
640
|
+
'Owner based guid generationn'() {
|
|
641
|
+
const Foo = () => {
|
|
642
|
+
return $mol_jsx("div", null,
|
|
643
|
+
$mol_jsx(Bar, { id: "middle", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
644
|
+
};
|
|
645
|
+
const Bar = (props) => {
|
|
646
|
+
return $mol_jsx("span", null, props.icon());
|
|
647
|
+
};
|
|
648
|
+
const dom = $mol_jsx(Foo, { id: "app" });
|
|
649
|
+
$mol_assert_equal(dom.outerHTML, '<div id="app" class="Foo"><span id="app/middle" class="Foo_middle Bar"><img id="app/icon" class="Foo_icon"></span></div>');
|
|
742
650
|
},
|
|
743
|
-
'
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
756
|
-
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
651
|
+
'Fail on same ids from different caller'() {
|
|
652
|
+
const Foo = () => {
|
|
653
|
+
return $mol_jsx("div", null,
|
|
654
|
+
$mol_jsx("img", { id: "icon" }),
|
|
655
|
+
$mol_jsx(Bar, { id: "bar", icon: () => $mol_jsx("img", { id: "icon" }) }));
|
|
656
|
+
};
|
|
657
|
+
const Bar = (props) => {
|
|
658
|
+
return $mol_jsx("span", null, props.icon());
|
|
659
|
+
};
|
|
660
|
+
$mol_assert_fail(() => $mol_jsx(Foo, { id: "foo" }), 'JSX already has tag with id "foo/icon"');
|
|
757
661
|
},
|
|
758
662
|
});
|
|
759
663
|
})($ || ($ = {}));
|
|
760
|
-
//mol/
|
|
664
|
+
//mol/jsx/jsx.test.tsx
|
|
761
665
|
;
|
|
762
666
|
"use strict";
|
|
763
667
|
var $;
|
|
@@ -882,7 +786,103 @@ var $;
|
|
|
882
786
|
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
883
787
|
}
|
|
884
788
|
})($ || ($ = {}));
|
|
885
|
-
//mol/compare/deep/deep.ts
|
|
789
|
+
//mol/compare/deep/deep.ts
|
|
790
|
+
;
|
|
791
|
+
"use strict";
|
|
792
|
+
var $;
|
|
793
|
+
(function ($) {
|
|
794
|
+
$mol_test({
|
|
795
|
+
'nulls & undefineds'() {
|
|
796
|
+
$mol_assert_ok($mol_compare_deep(null, null));
|
|
797
|
+
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
798
|
+
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
799
|
+
$mol_assert_not($mol_compare_deep({}, null));
|
|
800
|
+
},
|
|
801
|
+
'number'() {
|
|
802
|
+
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
803
|
+
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
804
|
+
$mol_assert_not($mol_compare_deep(1, 2));
|
|
805
|
+
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
806
|
+
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
807
|
+
},
|
|
808
|
+
'POJO'() {
|
|
809
|
+
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
810
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
811
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
812
|
+
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
813
|
+
$mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
814
|
+
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
815
|
+
},
|
|
816
|
+
'Array'() {
|
|
817
|
+
$mol_assert_ok($mol_compare_deep([], []));
|
|
818
|
+
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
819
|
+
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
820
|
+
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
821
|
+
},
|
|
822
|
+
'Non POJO are different'() {
|
|
823
|
+
class Thing extends Object {
|
|
824
|
+
}
|
|
825
|
+
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
826
|
+
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
827
|
+
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
828
|
+
},
|
|
829
|
+
'same POJOs with cyclic reference'() {
|
|
830
|
+
const a = { foo: {} };
|
|
831
|
+
a['self'] = a;
|
|
832
|
+
const b = { foo: {} };
|
|
833
|
+
b['self'] = b;
|
|
834
|
+
$mol_assert_ok($mol_compare_deep(a, b));
|
|
835
|
+
},
|
|
836
|
+
'Date'() {
|
|
837
|
+
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
838
|
+
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
839
|
+
},
|
|
840
|
+
'RegExp'() {
|
|
841
|
+
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
842
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
843
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
844
|
+
},
|
|
845
|
+
'Error'() {
|
|
846
|
+
$mol_assert_not($mol_compare_deep(new Error('xxx'), new Error('xxx')));
|
|
847
|
+
const fail = (message) => new Error(message);
|
|
848
|
+
$mol_assert_ok($mol_compare_deep(...['xxx', 'xxx'].map(msg => new Error(msg))));
|
|
849
|
+
$mol_assert_not($mol_compare_deep(...['xxx', 'yyy'].map(msg => new Error(msg))));
|
|
850
|
+
},
|
|
851
|
+
'Map'() {
|
|
852
|
+
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
853
|
+
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
854
|
+
$mol_assert_ok($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
855
|
+
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
856
|
+
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[3], 2]])));
|
|
857
|
+
},
|
|
858
|
+
'Set'() {
|
|
859
|
+
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
860
|
+
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
861
|
+
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
862
|
+
},
|
|
863
|
+
'Uint8Array'() {
|
|
864
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
865
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
866
|
+
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
867
|
+
},
|
|
868
|
+
'Custom comparator'() {
|
|
869
|
+
class User {
|
|
870
|
+
name;
|
|
871
|
+
rand;
|
|
872
|
+
constructor(name, rand = Math.random()) {
|
|
873
|
+
this.name = name;
|
|
874
|
+
this.rand = rand;
|
|
875
|
+
}
|
|
876
|
+
[Symbol.toPrimitive](mode) {
|
|
877
|
+
return this.name;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
881
|
+
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
882
|
+
},
|
|
883
|
+
});
|
|
884
|
+
})($ || ($ = {}));
|
|
885
|
+
//mol/compare/deep/deep.test.tsx
|
|
886
886
|
;
|
|
887
887
|
"use strict";
|
|
888
888
|
var $;
|
|
@@ -1139,6 +1139,106 @@ var $;
|
|
|
1139
1139
|
;
|
|
1140
1140
|
"use strict";
|
|
1141
1141
|
var $;
|
|
1142
|
+
(function ($) {
|
|
1143
|
+
const instances = new WeakSet();
|
|
1144
|
+
function $mol_delegate(proto, target) {
|
|
1145
|
+
const proxy = new Proxy(proto, {
|
|
1146
|
+
get: (_, field) => {
|
|
1147
|
+
const obj = target();
|
|
1148
|
+
let val = Reflect.get(obj, field);
|
|
1149
|
+
if (typeof val === 'function') {
|
|
1150
|
+
val = val.bind(obj);
|
|
1151
|
+
}
|
|
1152
|
+
return val;
|
|
1153
|
+
},
|
|
1154
|
+
has: (_, field) => Reflect.has(target(), field),
|
|
1155
|
+
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
1156
|
+
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
1157
|
+
ownKeys: () => Reflect.ownKeys(target()),
|
|
1158
|
+
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
1159
|
+
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
1160
|
+
isExtensible: () => Reflect.isExtensible(target()),
|
|
1161
|
+
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
1162
|
+
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
1163
|
+
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
1164
|
+
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
1165
|
+
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
1166
|
+
});
|
|
1167
|
+
instances.add(proxy);
|
|
1168
|
+
return proxy;
|
|
1169
|
+
}
|
|
1170
|
+
$.$mol_delegate = $mol_delegate;
|
|
1171
|
+
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
1172
|
+
value: (obj) => instances.has(obj),
|
|
1173
|
+
});
|
|
1174
|
+
})($ || ($ = {}));
|
|
1175
|
+
//mol/delegate/delegate.ts
|
|
1176
|
+
;
|
|
1177
|
+
"use strict";
|
|
1178
|
+
var $;
|
|
1179
|
+
(function ($) {
|
|
1180
|
+
$mol_test({
|
|
1181
|
+
'get'() {
|
|
1182
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1183
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
1184
|
+
},
|
|
1185
|
+
'has'() {
|
|
1186
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1187
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
1188
|
+
},
|
|
1189
|
+
'set'() {
|
|
1190
|
+
const target = { foo: 777 };
|
|
1191
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1192
|
+
proxy.foo = 123;
|
|
1193
|
+
$mol_assert_equal(target.foo, 123);
|
|
1194
|
+
},
|
|
1195
|
+
'getOwnPropertyDescriptor'() {
|
|
1196
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1197
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1198
|
+
value: 777,
|
|
1199
|
+
writable: true,
|
|
1200
|
+
enumerable: true,
|
|
1201
|
+
configurable: true,
|
|
1202
|
+
});
|
|
1203
|
+
},
|
|
1204
|
+
'ownKeys'() {
|
|
1205
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
1206
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1207
|
+
},
|
|
1208
|
+
'getPrototypeOf'() {
|
|
1209
|
+
class Foo {
|
|
1210
|
+
}
|
|
1211
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1212
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1213
|
+
},
|
|
1214
|
+
'setPrototypeOf'() {
|
|
1215
|
+
class Foo {
|
|
1216
|
+
}
|
|
1217
|
+
const target = {};
|
|
1218
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1219
|
+
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
1220
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
1221
|
+
},
|
|
1222
|
+
'instanceof'() {
|
|
1223
|
+
class Foo {
|
|
1224
|
+
}
|
|
1225
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1226
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1227
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1228
|
+
},
|
|
1229
|
+
'autobind'() {
|
|
1230
|
+
class Foo {
|
|
1231
|
+
}
|
|
1232
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1233
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1234
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1235
|
+
},
|
|
1236
|
+
});
|
|
1237
|
+
})($ || ($ = {}));
|
|
1238
|
+
//mol/delegate/delegate.test.ts
|
|
1239
|
+
;
|
|
1240
|
+
"use strict";
|
|
1241
|
+
var $;
|
|
1142
1242
|
(function ($) {
|
|
1143
1243
|
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
1144
1244
|
class $mol_tree extends $mol_object2 {
|
|
@@ -1469,106 +1569,6 @@ var $;
|
|
|
1469
1569
|
;
|
|
1470
1570
|
"use strict";
|
|
1471
1571
|
var $;
|
|
1472
|
-
(function ($) {
|
|
1473
|
-
const instances = new WeakSet();
|
|
1474
|
-
function $mol_delegate(proto, target) {
|
|
1475
|
-
const proxy = new Proxy(proto, {
|
|
1476
|
-
get: (_, field) => {
|
|
1477
|
-
const obj = target();
|
|
1478
|
-
let val = Reflect.get(obj, field);
|
|
1479
|
-
if (typeof val === 'function') {
|
|
1480
|
-
val = val.bind(obj);
|
|
1481
|
-
}
|
|
1482
|
-
return val;
|
|
1483
|
-
},
|
|
1484
|
-
has: (_, field) => Reflect.has(target(), field),
|
|
1485
|
-
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
1486
|
-
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
1487
|
-
ownKeys: () => Reflect.ownKeys(target()),
|
|
1488
|
-
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
1489
|
-
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
1490
|
-
isExtensible: () => Reflect.isExtensible(target()),
|
|
1491
|
-
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
1492
|
-
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
1493
|
-
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
1494
|
-
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
1495
|
-
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
1496
|
-
});
|
|
1497
|
-
instances.add(proxy);
|
|
1498
|
-
return proxy;
|
|
1499
|
-
}
|
|
1500
|
-
$.$mol_delegate = $mol_delegate;
|
|
1501
|
-
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
1502
|
-
value: (obj) => instances.has(obj),
|
|
1503
|
-
});
|
|
1504
|
-
})($ || ($ = {}));
|
|
1505
|
-
//mol/delegate/delegate.ts
|
|
1506
|
-
;
|
|
1507
|
-
"use strict";
|
|
1508
|
-
var $;
|
|
1509
|
-
(function ($) {
|
|
1510
|
-
$mol_test({
|
|
1511
|
-
'get'() {
|
|
1512
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1513
|
-
$mol_assert_equal(proxy.foo, 777);
|
|
1514
|
-
},
|
|
1515
|
-
'has'() {
|
|
1516
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1517
|
-
$mol_assert_equal('foo' in proxy, true);
|
|
1518
|
-
},
|
|
1519
|
-
'set'() {
|
|
1520
|
-
const target = { foo: 777 };
|
|
1521
|
-
const proxy = $mol_delegate({}, () => target);
|
|
1522
|
-
proxy.foo = 123;
|
|
1523
|
-
$mol_assert_equal(target.foo, 123);
|
|
1524
|
-
},
|
|
1525
|
-
'getOwnPropertyDescriptor'() {
|
|
1526
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1527
|
-
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1528
|
-
value: 777,
|
|
1529
|
-
writable: true,
|
|
1530
|
-
enumerable: true,
|
|
1531
|
-
configurable: true,
|
|
1532
|
-
});
|
|
1533
|
-
},
|
|
1534
|
-
'ownKeys'() {
|
|
1535
|
-
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
1536
|
-
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1537
|
-
},
|
|
1538
|
-
'getPrototypeOf'() {
|
|
1539
|
-
class Foo {
|
|
1540
|
-
}
|
|
1541
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
1542
|
-
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1543
|
-
},
|
|
1544
|
-
'setPrototypeOf'() {
|
|
1545
|
-
class Foo {
|
|
1546
|
-
}
|
|
1547
|
-
const target = {};
|
|
1548
|
-
const proxy = $mol_delegate({}, () => target);
|
|
1549
|
-
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
1550
|
-
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
1551
|
-
},
|
|
1552
|
-
'instanceof'() {
|
|
1553
|
-
class Foo {
|
|
1554
|
-
}
|
|
1555
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
1556
|
-
$mol_assert_ok(proxy instanceof Foo);
|
|
1557
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1558
|
-
},
|
|
1559
|
-
'autobind'() {
|
|
1560
|
-
class Foo {
|
|
1561
|
-
}
|
|
1562
|
-
const proxy = $mol_delegate({}, () => new Foo);
|
|
1563
|
-
$mol_assert_ok(proxy instanceof Foo);
|
|
1564
|
-
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1565
|
-
},
|
|
1566
|
-
});
|
|
1567
|
-
})($ || ($ = {}));
|
|
1568
|
-
//mol/delegate/delegate.test.ts
|
|
1569
|
-
;
|
|
1570
|
-
"use strict";
|
|
1571
|
-
var $;
|
|
1572
1572
|
(function ($_1) {
|
|
1573
1573
|
$mol_test({
|
|
1574
1574
|
'tree parsing'() {
|