mol_time_all 1.1.81 → 1.1.85
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 -156
- package/node.deps.json +1 -1
- package/node.esm.js +26 -26
- package/node.esm.js.map +1 -1
- package/node.js +26 -26
- package/node.js.map +1 -1
- package/node.test.js +287 -281
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/test.html +2 -2
- package/web.d.ts +0 -156
- package/web.deps.json +1 -1
- package/web.esm.js +26 -26
- package/web.esm.js.map +1 -1
- package/web.js +26 -26
- package/web.js.map +1 -1
- package/web.test.js +185 -179
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -19,7 +19,7 @@ var $;
|
|
|
19
19
|
(function ($) {
|
|
20
20
|
})($ || ($ = {}));
|
|
21
21
|
module.exports = $;
|
|
22
|
-
//mam.
|
|
22
|
+
//mam.ts
|
|
23
23
|
;
|
|
24
24
|
"use strict";
|
|
25
25
|
var $;
|
|
@@ -54,12 +54,12 @@ var $;
|
|
|
54
54
|
}
|
|
55
55
|
$.$mol_time_base = $mol_time_base;
|
|
56
56
|
})($ || ($ = {}));
|
|
57
|
-
//base.
|
|
57
|
+
//mol/time/base/base.ts
|
|
58
58
|
;
|
|
59
59
|
"use strict";
|
|
60
60
|
var $;
|
|
61
61
|
(function ($) {
|
|
62
|
-
class $mol_time_duration extends
|
|
62
|
+
class $mol_time_duration extends $mol_time_base {
|
|
63
63
|
constructor(config = 0) {
|
|
64
64
|
super();
|
|
65
65
|
if (typeof config === 'number') {
|
|
@@ -189,7 +189,7 @@ var $;
|
|
|
189
189
|
}
|
|
190
190
|
$.$mol_time_duration = $mol_time_duration;
|
|
191
191
|
})($ || ($ = {}));
|
|
192
|
-
//duration.
|
|
192
|
+
//mol/time/duration/duration.ts
|
|
193
193
|
;
|
|
194
194
|
"use strict";
|
|
195
195
|
var $;
|
|
@@ -199,7 +199,7 @@ var $;
|
|
|
199
199
|
}
|
|
200
200
|
$.$mol_fail = $mol_fail;
|
|
201
201
|
})($ || ($ = {}));
|
|
202
|
-
//fail.
|
|
202
|
+
//mol/fail/fail.ts
|
|
203
203
|
;
|
|
204
204
|
"use strict";
|
|
205
205
|
var $;
|
|
@@ -218,9 +218,9 @@ var $;
|
|
|
218
218
|
const numb = Number(str);
|
|
219
219
|
if (numb < max)
|
|
220
220
|
return numb;
|
|
221
|
-
|
|
221
|
+
$mol_fail(new Error(`Wrong time component ${str}`));
|
|
222
222
|
}
|
|
223
|
-
class $mol_time_moment extends
|
|
223
|
+
class $mol_time_moment extends $mol_time_base {
|
|
224
224
|
constructor(config = new Date) {
|
|
225
225
|
super();
|
|
226
226
|
if (typeof config === 'number')
|
|
@@ -242,7 +242,7 @@ var $;
|
|
|
242
242
|
if (parsed[6])
|
|
243
243
|
this.second = numb(parsed[6], 60);
|
|
244
244
|
if (parsed[7])
|
|
245
|
-
this.offset = new
|
|
245
|
+
this.offset = new $mol_time_duration(parsed[7]);
|
|
246
246
|
return;
|
|
247
247
|
}
|
|
248
248
|
if (config instanceof Date) {
|
|
@@ -253,7 +253,7 @@ var $;
|
|
|
253
253
|
this.minute = config.getMinutes();
|
|
254
254
|
this.second = config.getSeconds() + config.getMilliseconds() / 1000;
|
|
255
255
|
const offset = -config.getTimezoneOffset();
|
|
256
|
-
this.offset = new
|
|
256
|
+
this.offset = new $mol_time_duration({
|
|
257
257
|
hour: (offset < 0) ? Math.ceil(offset / 60) : Math.floor(offset / 60),
|
|
258
258
|
minute: offset % 60
|
|
259
259
|
});
|
|
@@ -265,7 +265,7 @@ var $;
|
|
|
265
265
|
this.hour = config.hour;
|
|
266
266
|
this.minute = config.minute;
|
|
267
267
|
this.second = config.second;
|
|
268
|
-
this.offset = config.offset == null ? config.offset : new
|
|
268
|
+
this.offset = config.offset == null ? config.offset : new $mol_time_duration(config.offset);
|
|
269
269
|
}
|
|
270
270
|
year;
|
|
271
271
|
month;
|
|
@@ -312,7 +312,7 @@ var $;
|
|
|
312
312
|
});
|
|
313
313
|
}
|
|
314
314
|
shift(config) {
|
|
315
|
-
const duration = new
|
|
315
|
+
const duration = new $mol_time_duration(config);
|
|
316
316
|
const moment = new $mol_time_moment().merge({
|
|
317
317
|
year: this.year,
|
|
318
318
|
month: this.month,
|
|
@@ -349,7 +349,7 @@ var $;
|
|
|
349
349
|
});
|
|
350
350
|
}
|
|
351
351
|
toOffset(config) {
|
|
352
|
-
const duration = new
|
|
352
|
+
const duration = new $mol_time_duration(config);
|
|
353
353
|
const offset = this.offset || new $mol_time_moment().offset;
|
|
354
354
|
let with_time = new $mol_time_moment('T00:00:00').merge(this);
|
|
355
355
|
const moment = with_time.shift(duration.summ(offset.mult(-1)));
|
|
@@ -583,46 +583,46 @@ var $;
|
|
|
583
583
|
}
|
|
584
584
|
$.$mol_time_moment = $mol_time_moment;
|
|
585
585
|
})($ || ($ = {}));
|
|
586
|
-
//moment.
|
|
586
|
+
//mol/time/moment/moment.ts
|
|
587
587
|
;
|
|
588
588
|
"use strict";
|
|
589
589
|
var $;
|
|
590
590
|
(function ($) {
|
|
591
|
-
class $mol_time_interval extends
|
|
591
|
+
class $mol_time_interval extends $mol_time_base {
|
|
592
592
|
constructor(config) {
|
|
593
593
|
super();
|
|
594
594
|
if (typeof config === 'string') {
|
|
595
595
|
var chunks = config.split('/');
|
|
596
596
|
if (chunks[0]) {
|
|
597
597
|
if (chunks[0][0].toUpperCase() === 'P') {
|
|
598
|
-
this._duration = new
|
|
598
|
+
this._duration = new $mol_time_duration(chunks[0]);
|
|
599
599
|
}
|
|
600
600
|
else {
|
|
601
|
-
this._start = new
|
|
601
|
+
this._start = new $mol_time_moment(chunks[0]);
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
604
|
else {
|
|
605
|
-
this._start = new
|
|
605
|
+
this._start = new $mol_time_moment();
|
|
606
606
|
}
|
|
607
607
|
if (chunks[1]) {
|
|
608
608
|
if (chunks[1][0].toUpperCase() === 'P') {
|
|
609
|
-
this._duration = new
|
|
609
|
+
this._duration = new $mol_time_duration(chunks[1]);
|
|
610
610
|
}
|
|
611
611
|
else {
|
|
612
|
-
this._end = new
|
|
612
|
+
this._end = new $mol_time_moment(chunks[1]);
|
|
613
613
|
}
|
|
614
614
|
}
|
|
615
615
|
else {
|
|
616
|
-
this._end = new
|
|
616
|
+
this._end = new $mol_time_moment();
|
|
617
617
|
}
|
|
618
618
|
return;
|
|
619
619
|
}
|
|
620
620
|
if (config.start !== undefined)
|
|
621
|
-
this._start = new
|
|
621
|
+
this._start = new $mol_time_moment(config.start);
|
|
622
622
|
if (config.end !== undefined)
|
|
623
|
-
this._end = new
|
|
623
|
+
this._end = new $mol_time_moment(config.end);
|
|
624
624
|
if (config.duration !== undefined)
|
|
625
|
-
this._duration = new
|
|
625
|
+
this._duration = new $mol_time_duration(config.duration);
|
|
626
626
|
}
|
|
627
627
|
_start;
|
|
628
628
|
get start() {
|
|
@@ -640,7 +640,7 @@ var $;
|
|
|
640
640
|
get duration() {
|
|
641
641
|
if (this._duration)
|
|
642
642
|
return this._duration;
|
|
643
|
-
return this._duration = new
|
|
643
|
+
return this._duration = new $mol_time_duration(this._end.valueOf() - this._start.valueOf());
|
|
644
644
|
}
|
|
645
645
|
toJSON() { return this.toString(); }
|
|
646
646
|
toString() {
|
|
@@ -652,7 +652,7 @@ var $;
|
|
|
652
652
|
}
|
|
653
653
|
$.$mol_time_interval = $mol_time_interval;
|
|
654
654
|
})($ || ($ = {}));
|
|
655
|
-
//interval.
|
|
655
|
+
//mol/time/interval/interval.ts
|
|
656
656
|
;
|
|
657
657
|
"use strict";
|
|
658
658
|
var $;
|
|
@@ -662,7 +662,7 @@ var $;
|
|
|
662
662
|
}
|
|
663
663
|
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
664
664
|
})($ || ($ = {}));
|
|
665
|
-
//hidden.
|
|
665
|
+
//mol/fail/hidden/hidden.ts
|
|
666
666
|
;
|
|
667
667
|
"use strict";
|
|
668
668
|
var $;
|
|
@@ -672,7 +672,7 @@ var $;
|
|
|
672
672
|
}
|
|
673
673
|
$.$mol_test_complete = $mol_test_complete;
|
|
674
674
|
})($ || ($ = {}));
|
|
675
|
-
//test.node.test.
|
|
675
|
+
//mol/test/test.node.test.ts
|
|
676
676
|
;
|
|
677
677
|
"use strict";
|
|
678
678
|
var $;
|
|
@@ -690,12 +690,18 @@ var $;
|
|
|
690
690
|
$_1.$mol_test_all = [];
|
|
691
691
|
async function $mol_test_run() {
|
|
692
692
|
for (var test of $_1.$mol_test_all) {
|
|
693
|
-
let context = Object.create(
|
|
693
|
+
let context = Object.create($$);
|
|
694
694
|
for (let mock of $_1.$mol_test_mocks)
|
|
695
695
|
await mock(context);
|
|
696
|
-
|
|
696
|
+
const res = test(context);
|
|
697
|
+
if (res instanceof Promise) {
|
|
698
|
+
await new Promise((done, fail) => {
|
|
699
|
+
res.then(done, fail);
|
|
700
|
+
setTimeout(() => fail(new Error('Test timeout: ' + test.name)), 1000);
|
|
701
|
+
});
|
|
702
|
+
}
|
|
697
703
|
}
|
|
698
|
-
|
|
704
|
+
$$.$mol_log3_done({
|
|
699
705
|
place: '$mol_test',
|
|
700
706
|
message: 'All tests passed',
|
|
701
707
|
count: $_1.$mol_test_all.length,
|
|
@@ -713,7 +719,7 @@ var $;
|
|
|
713
719
|
await $mol_test_run();
|
|
714
720
|
}
|
|
715
721
|
finally {
|
|
716
|
-
|
|
722
|
+
$$.$mol_test_complete();
|
|
717
723
|
}
|
|
718
724
|
}, 0);
|
|
719
725
|
}
|
|
@@ -726,10 +732,10 @@ var $;
|
|
|
726
732
|
for (let api of forbidden) {
|
|
727
733
|
context[api] = new Proxy(function () { }, {
|
|
728
734
|
get() {
|
|
729
|
-
$
|
|
735
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
730
736
|
},
|
|
731
737
|
apply() {
|
|
732
|
-
$
|
|
738
|
+
$mol_fail_hidden(new Error(`${api} is forbidden in tests`));
|
|
733
739
|
},
|
|
734
740
|
});
|
|
735
741
|
}
|
|
@@ -757,16 +763,16 @@ var $;
|
|
|
757
763
|
},
|
|
758
764
|
});
|
|
759
765
|
})($ || ($ = {}));
|
|
760
|
-
//test.test.
|
|
766
|
+
//mol/test/test.test.ts
|
|
761
767
|
;
|
|
762
768
|
"use strict";
|
|
763
769
|
var $;
|
|
764
770
|
(function ($) {
|
|
765
771
|
})($ || ($ = {}));
|
|
766
|
-
//context.
|
|
772
|
+
//mol/dom/context/context.ts
|
|
767
773
|
;
|
|
768
774
|
"use strict";
|
|
769
|
-
//node.
|
|
775
|
+
//node/node.ts
|
|
770
776
|
;
|
|
771
777
|
"use strict";
|
|
772
778
|
var $node = new Proxy({ require }, {
|
|
@@ -805,14 +811,14 @@ var $node = new Proxy({ require }, {
|
|
|
805
811
|
require = (req => Object.assign(function require(name) {
|
|
806
812
|
return $node[name];
|
|
807
813
|
}, req))(require);
|
|
808
|
-
//node.node.
|
|
814
|
+
//node/node.node.ts
|
|
809
815
|
;
|
|
810
816
|
"use strict";
|
|
811
817
|
var $;
|
|
812
818
|
(function ($) {
|
|
813
819
|
$.$mol_dom_context = new $node.jsdom.JSDOM('', { url: 'https://localhost/' }).window;
|
|
814
820
|
})($ || ($ = {}));
|
|
815
|
-
//context.node.
|
|
821
|
+
//mol/dom/context/context.node.ts
|
|
816
822
|
;
|
|
817
823
|
"use strict";
|
|
818
824
|
var $;
|
|
@@ -823,7 +829,7 @@ var $;
|
|
|
823
829
|
for (let view of childNodes) {
|
|
824
830
|
if (view == null)
|
|
825
831
|
continue;
|
|
826
|
-
if (view instanceof
|
|
832
|
+
if (view instanceof $mol_dom_context.Node) {
|
|
827
833
|
while (true) {
|
|
828
834
|
if (!nextNode) {
|
|
829
835
|
el.appendChild(view);
|
|
@@ -854,7 +860,7 @@ var $;
|
|
|
854
860
|
nextNode = nextNode.nextSibling;
|
|
855
861
|
}
|
|
856
862
|
else {
|
|
857
|
-
const textNode =
|
|
863
|
+
const textNode = $mol_dom_context.document.createTextNode(String(view));
|
|
858
864
|
el.insertBefore(textNode, nextNode);
|
|
859
865
|
}
|
|
860
866
|
}
|
|
@@ -867,88 +873,88 @@ var $;
|
|
|
867
873
|
}
|
|
868
874
|
$.$mol_dom_render_children = $mol_dom_render_children;
|
|
869
875
|
})($ || ($ = {}));
|
|
870
|
-
//children.
|
|
876
|
+
//mol/dom/render/children/children.ts
|
|
871
877
|
;
|
|
872
878
|
"use strict";
|
|
873
|
-
//error.
|
|
879
|
+
//mol/type/error/error.ts
|
|
874
880
|
;
|
|
875
881
|
"use strict";
|
|
876
|
-
//assert.test.
|
|
882
|
+
//mol/type/assert/assert.test.ts
|
|
877
883
|
;
|
|
878
884
|
"use strict";
|
|
879
|
-
//assert.
|
|
885
|
+
//mol/type/assert/assert.ts
|
|
880
886
|
;
|
|
881
887
|
"use strict";
|
|
882
|
-
//deep.test.
|
|
888
|
+
//mol/type/partial/deep/deep.test.ts
|
|
883
889
|
;
|
|
884
890
|
"use strict";
|
|
885
|
-
//deep.
|
|
891
|
+
//mol/type/partial/deep/deep.ts
|
|
886
892
|
;
|
|
887
893
|
"use strict";
|
|
888
894
|
var $;
|
|
889
895
|
(function ($) {
|
|
890
|
-
|
|
896
|
+
$mol_test({
|
|
891
897
|
'Make empty div'() {
|
|
892
|
-
|
|
898
|
+
$mol_assert_equal(($mol_jsx("div", null)).outerHTML, '<div></div>');
|
|
893
899
|
},
|
|
894
900
|
'Define native field'() {
|
|
895
|
-
const dom =
|
|
896
|
-
|
|
897
|
-
|
|
901
|
+
const dom = $mol_jsx("input", { value: '123' });
|
|
902
|
+
$mol_assert_equal(dom.outerHTML, '<input value="123">');
|
|
903
|
+
$mol_assert_equal(dom.value, '123');
|
|
898
904
|
},
|
|
899
905
|
'Define classes'() {
|
|
900
|
-
const dom =
|
|
901
|
-
|
|
906
|
+
const dom = $mol_jsx("div", { class: 'foo bar' });
|
|
907
|
+
$mol_assert_equal(dom.outerHTML, '<div class="foo bar"></div>');
|
|
902
908
|
},
|
|
903
909
|
'Define styles'() {
|
|
904
|
-
const dom =
|
|
905
|
-
|
|
910
|
+
const dom = $mol_jsx("div", { style: { color: 'red' } });
|
|
911
|
+
$mol_assert_equal(dom.outerHTML, '<div style="color: red;"></div>');
|
|
906
912
|
},
|
|
907
913
|
'Define dataset'() {
|
|
908
|
-
const dom =
|
|
909
|
-
|
|
914
|
+
const dom = $mol_jsx("div", { dataset: { foo: 'bar' } });
|
|
915
|
+
$mol_assert_equal(dom.outerHTML, '<div data-foo="bar"></div>');
|
|
910
916
|
},
|
|
911
917
|
'Define attributes'() {
|
|
912
|
-
const dom =
|
|
913
|
-
|
|
918
|
+
const dom = $mol_jsx("div", { lang: "ru", hidden: true });
|
|
919
|
+
$mol_assert_equal(dom.outerHTML, '<div lang="ru" hidden=""></div>');
|
|
914
920
|
},
|
|
915
921
|
'Define child nodes'() {
|
|
916
|
-
const dom =
|
|
922
|
+
const dom = $mol_jsx("div", null,
|
|
917
923
|
"hello",
|
|
918
|
-
|
|
924
|
+
$mol_jsx("strong", null, "world"),
|
|
919
925
|
"!");
|
|
920
|
-
|
|
926
|
+
$mol_assert_equal(dom.outerHTML, '<div>hello<strong>world</strong>!</div>');
|
|
921
927
|
},
|
|
922
928
|
'Function as component'() {
|
|
923
929
|
const Button = ({ hint }, target) => {
|
|
924
|
-
return
|
|
930
|
+
return $mol_jsx("button", { title: hint }, target());
|
|
925
931
|
};
|
|
926
|
-
const dom =
|
|
927
|
-
|
|
932
|
+
const dom = $mol_jsx(Button, { id: "/foo", hint: "click me" }, () => 'hey!');
|
|
933
|
+
$mol_assert_equal(dom.outerHTML, '<button title="click me" id="/foo">hey!</button>');
|
|
928
934
|
},
|
|
929
935
|
'Nested guid generation'() {
|
|
930
936
|
const Foo = () => {
|
|
931
|
-
return
|
|
932
|
-
|
|
933
|
-
|
|
937
|
+
return $mol_jsx("div", null,
|
|
938
|
+
$mol_jsx(Bar, { id: "/bar" },
|
|
939
|
+
$mol_jsx("img", { id: "/icon" })));
|
|
934
940
|
};
|
|
935
941
|
const Bar = (props, icon) => {
|
|
936
|
-
return
|
|
942
|
+
return $mol_jsx("span", null, icon);
|
|
937
943
|
};
|
|
938
|
-
const dom =
|
|
939
|
-
|
|
944
|
+
const dom = $mol_jsx(Foo, { id: "/foo" });
|
|
945
|
+
$mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
|
|
940
946
|
},
|
|
941
947
|
'Fail on non unique ids'() {
|
|
942
948
|
const App = () => {
|
|
943
|
-
return
|
|
944
|
-
|
|
945
|
-
|
|
949
|
+
return $mol_jsx("div", null,
|
|
950
|
+
$mol_jsx("span", { id: "/bar" }),
|
|
951
|
+
$mol_jsx("span", { id: "/bar" }));
|
|
946
952
|
};
|
|
947
|
-
|
|
953
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
|
|
948
954
|
},
|
|
949
955
|
});
|
|
950
956
|
})($ || ($ = {}));
|
|
951
|
-
//jsx.test.
|
|
957
|
+
//mol/jsx/jsx.test.tsx
|
|
952
958
|
;
|
|
953
959
|
"use strict";
|
|
954
960
|
var $;
|
|
@@ -957,15 +963,15 @@ var $;
|
|
|
957
963
|
$.$mol_jsx_booked = null;
|
|
958
964
|
$.$mol_jsx_document = {
|
|
959
965
|
getElementById: () => null,
|
|
960
|
-
createElementNS: (space, name) =>
|
|
961
|
-
createDocumentFragment: () =>
|
|
966
|
+
createElementNS: (space, name) => $mol_dom_context.document.createElementNS(space, name),
|
|
967
|
+
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
962
968
|
};
|
|
963
969
|
$.$mol_jsx_frag = '';
|
|
964
970
|
function $mol_jsx(Elem, props, ...childNodes) {
|
|
965
971
|
const id = props && props.id || '';
|
|
966
972
|
if (Elem && $.$mol_jsx_booked) {
|
|
967
973
|
if ($.$mol_jsx_booked.has(id)) {
|
|
968
|
-
|
|
974
|
+
$mol_fail(new Error(`JSX already has tag with id ${JSON.stringify(id)}`));
|
|
969
975
|
}
|
|
970
976
|
else {
|
|
971
977
|
$.$mol_jsx_booked.add(id);
|
|
@@ -1004,7 +1010,7 @@ var $;
|
|
|
1004
1010
|
? $.$mol_jsx_document.createElementNS(props?.xmlns ?? 'http://www.w3.org/1999/xhtml', Elem)
|
|
1005
1011
|
: $.$mol_jsx_document.createDocumentFragment();
|
|
1006
1012
|
}
|
|
1007
|
-
|
|
1013
|
+
$mol_dom_render_children(node, [].concat(...childNodes));
|
|
1008
1014
|
if (!Elem)
|
|
1009
1015
|
return node;
|
|
1010
1016
|
for (const key in props) {
|
|
@@ -1030,77 +1036,77 @@ var $;
|
|
|
1030
1036
|
}
|
|
1031
1037
|
$.$mol_jsx = $mol_jsx;
|
|
1032
1038
|
})($ || ($ = {}));
|
|
1033
|
-
//jsx.
|
|
1039
|
+
//mol/jsx/jsx.ts
|
|
1034
1040
|
;
|
|
1035
1041
|
"use strict";
|
|
1036
1042
|
var $;
|
|
1037
1043
|
(function ($) {
|
|
1038
|
-
|
|
1044
|
+
$mol_test({
|
|
1039
1045
|
'nulls & undefineds'() {
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1046
|
+
$mol_assert_ok($mol_compare_deep(null, null));
|
|
1047
|
+
$mol_assert_ok($mol_compare_deep(undefined, undefined));
|
|
1048
|
+
$mol_assert_not($mol_compare_deep(undefined, null));
|
|
1049
|
+
$mol_assert_not($mol_compare_deep({}, null));
|
|
1044
1050
|
},
|
|
1045
1051
|
'number'() {
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1052
|
+
$mol_assert_ok($mol_compare_deep(1, 1));
|
|
1053
|
+
$mol_assert_ok($mol_compare_deep(Number.NaN, Number.NaN));
|
|
1054
|
+
$mol_assert_not($mol_compare_deep(1, 2));
|
|
1055
|
+
$mol_assert_ok($mol_compare_deep(Object(1), Object(1)));
|
|
1056
|
+
$mol_assert_not($mol_compare_deep(Object(1), Object(2)));
|
|
1051
1057
|
},
|
|
1052
1058
|
'POJO'() {
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
+
$mol_assert_ok($mol_compare_deep({}, {}));
|
|
1060
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
1061
|
+
$mol_assert_not($mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
1062
|
+
$mol_assert_not($mol_compare_deep({}, { a: undefined }));
|
|
1063
|
+
$mol_assert_ok($mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
1064
|
+
$mol_assert_ok($mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
1059
1065
|
},
|
|
1060
1066
|
'Array'() {
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1067
|
+
$mol_assert_ok($mol_compare_deep([], []));
|
|
1068
|
+
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
1069
|
+
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
1070
|
+
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
1065
1071
|
},
|
|
1066
1072
|
'Non POJO are different'() {
|
|
1067
1073
|
class Thing extends Object {
|
|
1068
1074
|
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1075
|
+
$mol_assert_not($mol_compare_deep(new Thing, new Thing));
|
|
1076
|
+
$mol_assert_not($mol_compare_deep(() => 1, () => 1));
|
|
1077
|
+
$mol_assert_not($mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
1072
1078
|
},
|
|
1073
1079
|
'same POJOs with cyclic reference'() {
|
|
1074
1080
|
const a = { foo: {} };
|
|
1075
1081
|
a['self'] = a;
|
|
1076
1082
|
const b = { foo: {} };
|
|
1077
1083
|
b['self'] = b;
|
|
1078
|
-
|
|
1084
|
+
$mol_assert_ok($mol_compare_deep(a, b));
|
|
1079
1085
|
},
|
|
1080
1086
|
'Date'() {
|
|
1081
|
-
|
|
1082
|
-
|
|
1087
|
+
$mol_assert_ok($mol_compare_deep(new Date(12345), new Date(12345)));
|
|
1088
|
+
$mol_assert_not($mol_compare_deep(new Date(12345), new Date(12346)));
|
|
1083
1089
|
},
|
|
1084
1090
|
'RegExp'() {
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1091
|
+
$mol_assert_ok($mol_compare_deep(/\x22/mig, /\x22/mig));
|
|
1092
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x21/mig));
|
|
1093
|
+
$mol_assert_not($mol_compare_deep(/\x22/mig, /\x22/mg));
|
|
1088
1094
|
},
|
|
1089
1095
|
'Map'() {
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1096
|
+
$mol_assert_ok($mol_compare_deep(new Map, new Map));
|
|
1097
|
+
$mol_assert_ok($mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
1098
|
+
$mol_assert_not($mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
1099
|
+
$mol_assert_not($mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
1094
1100
|
},
|
|
1095
1101
|
'Set'() {
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1102
|
+
$mol_assert_ok($mol_compare_deep(new Set, new Set));
|
|
1103
|
+
$mol_assert_ok($mol_compare_deep(new Set([1, [2]]), new Set([1, [2]])));
|
|
1104
|
+
$mol_assert_not($mol_compare_deep(new Set([1]), new Set([2])));
|
|
1099
1105
|
},
|
|
1100
1106
|
'Uint8Array'() {
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1107
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array, new Uint8Array));
|
|
1108
|
+
$mol_assert_ok($mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
1109
|
+
$mol_assert_not($mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
1104
1110
|
},
|
|
1105
1111
|
'Custom comparator'() {
|
|
1106
1112
|
class User {
|
|
@@ -1114,17 +1120,17 @@ var $;
|
|
|
1114
1120
|
return this.name;
|
|
1115
1121
|
}
|
|
1116
1122
|
}
|
|
1117
|
-
|
|
1118
|
-
|
|
1123
|
+
$mol_assert_ok($mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
1124
|
+
$mol_assert_not($mol_compare_deep(new User('Jin'), new User('John')));
|
|
1119
1125
|
},
|
|
1120
1126
|
});
|
|
1121
1127
|
})($ || ($ = {}));
|
|
1122
|
-
//deep.test.
|
|
1128
|
+
//mol/compare/deep/deep.test.tsx
|
|
1123
1129
|
;
|
|
1124
1130
|
"use strict";
|
|
1125
1131
|
var $;
|
|
1126
1132
|
(function ($) {
|
|
1127
|
-
|
|
1133
|
+
$.$mol_compare_deep_cache = new WeakMap();
|
|
1128
1134
|
function $mol_compare_deep(left, right) {
|
|
1129
1135
|
if (Object.is(left, right))
|
|
1130
1136
|
return true;
|
|
@@ -1150,7 +1156,7 @@ var $;
|
|
|
1150
1156
|
return Object.is(left.valueOf(), right['valueOf']());
|
|
1151
1157
|
if (left instanceof RegExp)
|
|
1152
1158
|
return left.source === right['source'] && left.flags === right['flags'];
|
|
1153
|
-
let left_cache =
|
|
1159
|
+
let left_cache = $.$mol_compare_deep_cache.get(left);
|
|
1154
1160
|
if (left_cache) {
|
|
1155
1161
|
const right_cache = left_cache.get(right);
|
|
1156
1162
|
if (typeof right_cache === 'boolean')
|
|
@@ -1158,7 +1164,7 @@ var $;
|
|
|
1158
1164
|
}
|
|
1159
1165
|
else {
|
|
1160
1166
|
left_cache = new WeakMap([[right, true]]);
|
|
1161
|
-
|
|
1167
|
+
$.$mol_compare_deep_cache.set(left, left_cache);
|
|
1162
1168
|
}
|
|
1163
1169
|
let result;
|
|
1164
1170
|
try {
|
|
@@ -1242,50 +1248,50 @@ var $;
|
|
|
1242
1248
|
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
1243
1249
|
}
|
|
1244
1250
|
})($ || ($ = {}));
|
|
1245
|
-
//deep.
|
|
1251
|
+
//mol/compare/deep/deep.ts
|
|
1246
1252
|
;
|
|
1247
1253
|
"use strict";
|
|
1248
1254
|
var $;
|
|
1249
1255
|
(function ($) {
|
|
1250
1256
|
function $mol_dom_serialize(node) {
|
|
1251
|
-
const serializer = new
|
|
1257
|
+
const serializer = new $mol_dom_context.XMLSerializer;
|
|
1252
1258
|
return serializer.serializeToString(node);
|
|
1253
1259
|
}
|
|
1254
1260
|
$.$mol_dom_serialize = $mol_dom_serialize;
|
|
1255
1261
|
})($ || ($ = {}));
|
|
1256
|
-
//serialize.
|
|
1262
|
+
//mol/dom/serialize/serialize.ts
|
|
1257
1263
|
;
|
|
1258
1264
|
"use strict";
|
|
1259
1265
|
var $;
|
|
1260
1266
|
(function ($) {
|
|
1261
|
-
|
|
1267
|
+
$mol_test({
|
|
1262
1268
|
'must be false'() {
|
|
1263
|
-
|
|
1269
|
+
$mol_assert_not(0);
|
|
1264
1270
|
},
|
|
1265
1271
|
'must be true'() {
|
|
1266
|
-
|
|
1272
|
+
$mol_assert_ok(1);
|
|
1267
1273
|
},
|
|
1268
1274
|
'two must be equal'() {
|
|
1269
|
-
|
|
1275
|
+
$mol_assert_equal(2, 2);
|
|
1270
1276
|
},
|
|
1271
1277
|
'three must be equal'() {
|
|
1272
|
-
|
|
1278
|
+
$mol_assert_equal(2, 2, 2);
|
|
1273
1279
|
},
|
|
1274
1280
|
'two must be unique'() {
|
|
1275
|
-
|
|
1281
|
+
$mol_assert_unique([3], [3]);
|
|
1276
1282
|
},
|
|
1277
1283
|
'three must be unique'() {
|
|
1278
|
-
|
|
1284
|
+
$mol_assert_unique([3], [3], [3]);
|
|
1279
1285
|
},
|
|
1280
1286
|
'two must be alike'() {
|
|
1281
|
-
|
|
1287
|
+
$mol_assert_like([3], [3]);
|
|
1282
1288
|
},
|
|
1283
1289
|
'three must be alike'() {
|
|
1284
|
-
|
|
1290
|
+
$mol_assert_like([3], [3], [3]);
|
|
1285
1291
|
},
|
|
1286
1292
|
});
|
|
1287
1293
|
})($ || ($ = {}));
|
|
1288
|
-
//assert.test.
|
|
1294
|
+
//mol/assert/assert.test.ts
|
|
1289
1295
|
;
|
|
1290
1296
|
"use strict";
|
|
1291
1297
|
var $;
|
|
@@ -1293,13 +1299,13 @@ var $;
|
|
|
1293
1299
|
function $mol_assert_ok(value) {
|
|
1294
1300
|
if (value)
|
|
1295
1301
|
return;
|
|
1296
|
-
|
|
1302
|
+
$mol_fail(new Error(`${value} ≠ true`));
|
|
1297
1303
|
}
|
|
1298
1304
|
$.$mol_assert_ok = $mol_assert_ok;
|
|
1299
1305
|
function $mol_assert_not(value) {
|
|
1300
1306
|
if (!value)
|
|
1301
1307
|
return;
|
|
1302
|
-
|
|
1308
|
+
$mol_fail(new Error(`${value} ≠ false`));
|
|
1303
1309
|
}
|
|
1304
1310
|
$.$mol_assert_not = $mol_assert_not;
|
|
1305
1311
|
function $mol_assert_fail(handler, ErrorRight) {
|
|
@@ -1323,7 +1329,7 @@ var $;
|
|
|
1323
1329
|
finally {
|
|
1324
1330
|
$.$mol_fail = fail;
|
|
1325
1331
|
}
|
|
1326
|
-
|
|
1332
|
+
$mol_fail(new Error('Not failed'));
|
|
1327
1333
|
}
|
|
1328
1334
|
$.$mol_assert_fail = $mol_assert_fail;
|
|
1329
1335
|
function $mol_assert_equal(...args) {
|
|
@@ -1334,7 +1340,7 @@ var $;
|
|
|
1334
1340
|
if (Number.isNaN(args[i]) && Number.isNaN(args[j]))
|
|
1335
1341
|
continue;
|
|
1336
1342
|
if (args[i] !== args[j])
|
|
1337
|
-
|
|
1343
|
+
$mol_fail(new Error(`Not equal (${i + 1}:${j + 1})\n${args[i]}\n${args[j]}`));
|
|
1338
1344
|
}
|
|
1339
1345
|
}
|
|
1340
1346
|
}
|
|
@@ -1345,7 +1351,7 @@ var $;
|
|
|
1345
1351
|
if (i === j)
|
|
1346
1352
|
continue;
|
|
1347
1353
|
if (args[i] === args[j] || (Number.isNaN(args[i]) && Number.isNaN(args[j]))) {
|
|
1348
|
-
|
|
1354
|
+
$mol_fail(new Error(`args[${i}] = args[${j}] = ${args[i]}`));
|
|
1349
1355
|
}
|
|
1350
1356
|
}
|
|
1351
1357
|
}
|
|
@@ -1353,7 +1359,7 @@ var $;
|
|
|
1353
1359
|
$.$mol_assert_unique = $mol_assert_unique;
|
|
1354
1360
|
function $mol_assert_like(head, ...tail) {
|
|
1355
1361
|
for (let [index, value] of Object.entries(tail)) {
|
|
1356
|
-
if (
|
|
1362
|
+
if (!$mol_compare_deep(value, head)) {
|
|
1357
1363
|
const print = (val) => {
|
|
1358
1364
|
if (!val)
|
|
1359
1365
|
return val;
|
|
@@ -1369,118 +1375,118 @@ var $;
|
|
|
1369
1375
|
return val;
|
|
1370
1376
|
}
|
|
1371
1377
|
};
|
|
1372
|
-
return
|
|
1378
|
+
return $mol_fail(new Error(`Not like (1:${+index + 2})\n${print(head)}\n---\n${print(value)}`));
|
|
1373
1379
|
}
|
|
1374
1380
|
}
|
|
1375
1381
|
}
|
|
1376
1382
|
$.$mol_assert_like = $mol_assert_like;
|
|
1377
1383
|
function $mol_assert_dom(left, right) {
|
|
1378
|
-
$mol_assert_equal(
|
|
1384
|
+
$mol_assert_equal($mol_dom_serialize(left), $mol_dom_serialize(right));
|
|
1379
1385
|
}
|
|
1380
1386
|
$.$mol_assert_dom = $mol_assert_dom;
|
|
1381
1387
|
})($ || ($ = {}));
|
|
1382
|
-
//assert.
|
|
1388
|
+
//mol/assert/assert.ts
|
|
1383
1389
|
;
|
|
1384
1390
|
"use strict";
|
|
1385
1391
|
var $;
|
|
1386
1392
|
(function ($) {
|
|
1387
|
-
|
|
1393
|
+
$mol_test({
|
|
1388
1394
|
'parse and serial'() {
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1395
|
+
$mol_assert_equal(new $mol_time_duration('P42.1Y').toString(), 'P42.1YT');
|
|
1396
|
+
$mol_assert_equal(new $mol_time_duration('P42.1M').toString(), 'P42.1MT');
|
|
1397
|
+
$mol_assert_equal(new $mol_time_duration('P42.1D').toString(), 'P42.1DT');
|
|
1398
|
+
$mol_assert_equal(new $mol_time_duration('PT42.1h').toString(), 'PT42.1H');
|
|
1399
|
+
$mol_assert_equal(new $mol_time_duration('PT42.1m').toString(), 'PT42.1M');
|
|
1400
|
+
$mol_assert_equal(new $mol_time_duration('PT42.1s').toString(), 'PT42.1S');
|
|
1401
|
+
$mol_assert_equal(new $mol_time_duration('P1Y2M3DT4h5m6.7s').toString(), 'P1Y2M3DT4H5M6.7S');
|
|
1396
1402
|
},
|
|
1397
1403
|
'format typed'() {
|
|
1398
|
-
|
|
1404
|
+
$mol_assert_equal(new $mol_time_duration('P1Y2M3DT4h5m6s').toString('P#Y#M#DT#h#m#s'), 'P1Y2M3DT4H5M6S');
|
|
1399
1405
|
},
|
|
1400
1406
|
'comparison'() {
|
|
1401
1407
|
const iso = 'P1Y1M1DT1h1m1s';
|
|
1402
|
-
|
|
1408
|
+
$mol_assert_like(new $mol_time_duration(iso), new $mol_time_duration(iso));
|
|
1403
1409
|
},
|
|
1404
1410
|
});
|
|
1405
1411
|
})($ || ($ = {}));
|
|
1406
|
-
//duration.test.
|
|
1412
|
+
//mol/time/duration/duration.test.ts
|
|
1407
1413
|
;
|
|
1408
1414
|
"use strict";
|
|
1409
1415
|
var $;
|
|
1410
1416
|
(function ($) {
|
|
1411
|
-
|
|
1417
|
+
$mol_test({
|
|
1412
1418
|
'parse and serial'() {
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1419
|
+
$mol_assert_equal(new $mol_time_moment('2014').toString(), '2014');
|
|
1420
|
+
$mol_assert_equal(new $mol_time_moment('2014-01').toString(), '2014-01');
|
|
1421
|
+
$mol_assert_equal(new $mol_time_moment('2014-01-02').toString(), '2014-01-02');
|
|
1422
|
+
$mol_assert_equal(new $mol_time_moment('2014-01-02T03').toString(), '2014-01-02T03');
|
|
1423
|
+
$mol_assert_equal(new $mol_time_moment('2014-01-02T03:04').toString(), '2014-01-02T03:04');
|
|
1424
|
+
$mol_assert_equal(new $mol_time_moment('2014-01-02T03:04:05').toString(), '2014-01-02T03:04:05');
|
|
1425
|
+
$mol_assert_equal(new $mol_time_moment('2014-01-02T03:04:05.006').toString(), '2014-01-02T03:04:05.006');
|
|
1426
|
+
$mol_assert_equal(new $mol_time_moment('2014-01-02T03:04:05.006Z').toString(), '2014-01-02T03:04:05.006+00:00');
|
|
1427
|
+
$mol_assert_equal(new $mol_time_moment('2014-01-02T03:04:05.006+07:00').toString(), '2014-01-02T03:04:05.006+07:00');
|
|
1428
|
+
$mol_assert_equal(new $mol_time_moment('2014-01-02T03:04:05+07:08').toString(), '2014-01-02T03:04:05+07:08');
|
|
1429
|
+
$mol_assert_equal(new $mol_time_moment('2014-01-02T03:04+07:08').toString(), '2014-01-02T03:04+07:08');
|
|
1430
|
+
$mol_assert_equal(new $mol_time_moment('T03:04+07:08').toString(), 'T03:04+07:08');
|
|
1431
|
+
$mol_assert_equal(new $mol_time_moment('T03:04:05').toString(), 'T03:04:05');
|
|
1432
|
+
$mol_assert_equal(new $mol_time_moment('T03:04').toString(), 'T03:04');
|
|
1433
|
+
$mol_assert_equal(new $mol_time_moment('T03').toString(), 'T03');
|
|
1428
1434
|
},
|
|
1429
1435
|
'format simple'() {
|
|
1430
|
-
|
|
1436
|
+
$mol_assert_equal(new $mol_time_moment('2014-01-02T01:02:03.000000').toString('AD YY-M-D h:m:s'), '21 14-1-2 1:2:3');
|
|
1431
1437
|
},
|
|
1432
1438
|
'format padded'() {
|
|
1433
|
-
|
|
1439
|
+
$mol_assert_equal(new $mol_time_moment('2014-01-02T01:02:03.000').toString('YYYY-MM-DD hh:mm:ss'), '2014-01-02 01:02:03');
|
|
1434
1440
|
},
|
|
1435
1441
|
'format time zone'() {
|
|
1436
|
-
|
|
1442
|
+
$mol_assert_equal(new $mol_time_moment('2014-01-02T01:02:03+05:00').toString('Z'), '+05:00');
|
|
1437
1443
|
},
|
|
1438
1444
|
'format names'() {
|
|
1439
|
-
|
|
1445
|
+
$mol_assert_ok(new $mol_time_moment('2014-01-02T01:02:03.000').toString('Month Mon | WeekDay WD'));
|
|
1440
1446
|
},
|
|
1441
1447
|
'shifting'() {
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1448
|
+
$mol_assert_equal(new $mol_time_moment('T15:54:58.243+03:00').shift({}).toString(), 'T15:54:58.243+03:00');
|
|
1449
|
+
$mol_assert_equal(new $mol_time_moment('2014-01-02').shift('P1Y').toString(), '2015-01-02');
|
|
1450
|
+
$mol_assert_equal(new $mol_time_moment('2014-01-02').shift('P12M').toString(), '2015-01-02');
|
|
1451
|
+
$mol_assert_equal(new $mol_time_moment('2014-01-02').shift('P365D').toString(), '2015-01-02');
|
|
1452
|
+
$mol_assert_equal(new $mol_time_moment('2014-01-02').shift('PT8760h').toString(), '2015-01-02');
|
|
1453
|
+
$mol_assert_equal(new $mol_time_moment('2014-01').shift('PT8760h').toString(), '2015-01');
|
|
1454
|
+
$mol_assert_equal(new $mol_time_moment('2014-01').shift('PT-8760h').toString(), '2013-01');
|
|
1449
1455
|
},
|
|
1450
1456
|
'normalization'() {
|
|
1451
|
-
|
|
1457
|
+
$mol_assert_equal(new $mol_time_moment({ year: 2015, month: 6, day: 34 }).normal.toString(), '2015-08-04');
|
|
1452
1458
|
},
|
|
1453
1459
|
'iso week day'() {
|
|
1454
|
-
|
|
1455
|
-
|
|
1460
|
+
$mol_assert_equal(new $mol_time_moment('2017-09-17').weekday, $mol_time_moment_weekdays.sunday);
|
|
1461
|
+
$mol_assert_equal(new $mol_time_moment('2017-09-18').weekday, $mol_time_moment_weekdays.monday);
|
|
1456
1462
|
},
|
|
1457
1463
|
'change offset'() {
|
|
1458
|
-
|
|
1464
|
+
$mol_assert_equal(new $mol_time_moment('2021-04-10 +03:00').toOffset('Z').toString(), '2021-04-09T21:00:00+00:00');
|
|
1459
1465
|
},
|
|
1460
1466
|
'comparison'() {
|
|
1461
1467
|
const iso = '2021-01-02T03:04:05.678+09:10';
|
|
1462
|
-
|
|
1468
|
+
$mol_assert_like(new $mol_time_moment(iso), new $mol_time_moment(iso));
|
|
1463
1469
|
},
|
|
1464
1470
|
});
|
|
1465
1471
|
})($ || ($ = {}));
|
|
1466
|
-
//moment.test.
|
|
1472
|
+
//mol/time/moment/moment.test.ts
|
|
1467
1473
|
;
|
|
1468
1474
|
"use strict";
|
|
1469
1475
|
var $;
|
|
1470
1476
|
(function ($) {
|
|
1471
|
-
|
|
1477
|
+
$mol_test({
|
|
1472
1478
|
'triplets'() {
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1479
|
+
$mol_assert_equal(new $mol_time_interval('2015-01-01/P1M').end.toString(), '2015-02-01');
|
|
1480
|
+
$mol_assert_equal(new $mol_time_interval('P1M/2015-02-01').start.toString(), '2015-01-01');
|
|
1481
|
+
$mol_assert_equal(new $mol_time_interval('2015-01-01/2015-02-01').duration.toString(), 'PT2678400S');
|
|
1476
1482
|
},
|
|
1477
1483
|
'comparison'() {
|
|
1478
1484
|
const iso = '2021-01-02/2022-03-04';
|
|
1479
|
-
|
|
1485
|
+
$mol_assert_like(new $mol_time_interval(iso), new $mol_time_interval(iso));
|
|
1480
1486
|
},
|
|
1481
1487
|
});
|
|
1482
1488
|
})($ || ($ = {}));
|
|
1483
|
-
//interval.test.
|
|
1489
|
+
//mol/time/interval/interval.test.ts
|
|
1484
1490
|
;
|
|
1485
1491
|
"use strict";
|
|
1486
1492
|
var $;
|
|
@@ -1504,7 +1510,7 @@ var $;
|
|
|
1504
1510
|
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
1505
1511
|
$.$mol_log3_stack = [];
|
|
1506
1512
|
})($ || ($ = {}));
|
|
1507
|
-
//log3.
|
|
1513
|
+
//mol/log3/log3.ts
|
|
1508
1514
|
;
|
|
1509
1515
|
"use strict";
|
|
1510
1516
|
var $;
|
|
@@ -1532,12 +1538,12 @@ var $;
|
|
|
1532
1538
|
$.$mol_log3_rise = $mol_log3_node_make('log', 'stdout', 'rise', 'magenta');
|
|
1533
1539
|
$.$mol_log3_area = $mol_log3_node_make('log', 'stdout', 'area', 'cyan');
|
|
1534
1540
|
})($ || ($ = {}));
|
|
1535
|
-
//log3.node.
|
|
1541
|
+
//mol/log3/log3.node.ts
|
|
1536
1542
|
;
|
|
1537
1543
|
"use strict";
|
|
1538
1544
|
var $;
|
|
1539
1545
|
(function ($_1) {
|
|
1540
|
-
$
|
|
1546
|
+
$mol_test_mocks.push($ => {
|
|
1541
1547
|
$.$mol_log3_come = () => { };
|
|
1542
1548
|
$.$mol_log3_done = () => { };
|
|
1543
1549
|
$.$mol_log3_fail = () => { };
|
|
@@ -1546,7 +1552,7 @@ var $;
|
|
|
1546
1552
|
$.$mol_log3_area = () => () => { };
|
|
1547
1553
|
});
|
|
1548
1554
|
})($ || ($ = {}));
|
|
1549
|
-
//log3.test.
|
|
1555
|
+
//mol/log3/log3.test.ts
|
|
1550
1556
|
;
|
|
1551
1557
|
"use strict";
|
|
1552
1558
|
var $;
|
|
@@ -1556,7 +1562,7 @@ var $;
|
|
|
1556
1562
|
}
|
|
1557
1563
|
$.$mol_env = $mol_env;
|
|
1558
1564
|
})($ || ($ = {}));
|
|
1559
|
-
//env.
|
|
1565
|
+
//mol/env/env.ts
|
|
1560
1566
|
;
|
|
1561
1567
|
"use strict";
|
|
1562
1568
|
var $;
|
|
@@ -1565,7 +1571,7 @@ var $;
|
|
|
1565
1571
|
return this.process.env;
|
|
1566
1572
|
};
|
|
1567
1573
|
})($ || ($ = {}));
|
|
1568
|
-
//env.node.
|
|
1574
|
+
//mol/env/env.node.ts
|
|
1569
1575
|
;
|
|
1570
1576
|
"use strict";
|
|
1571
1577
|
var $;
|
|
@@ -1585,14 +1591,14 @@ var $;
|
|
|
1585
1591
|
env: this.$mol_env(),
|
|
1586
1592
|
});
|
|
1587
1593
|
if (res.status || res.error)
|
|
1588
|
-
return
|
|
1594
|
+
return $mol_fail(res.error || new Error(res.stderr.toString()));
|
|
1589
1595
|
if (!res.stdout)
|
|
1590
1596
|
res.stdout = Buffer.from([]);
|
|
1591
1597
|
return res;
|
|
1592
1598
|
}
|
|
1593
1599
|
$.$mol_exec = $mol_exec;
|
|
1594
1600
|
})($ || ($ = {}));
|
|
1595
|
-
//exec.node.
|
|
1601
|
+
//mol/exec/exec.node.ts
|
|
1596
1602
|
;
|
|
1597
1603
|
"use strict";
|
|
1598
1604
|
var $;
|
|
@@ -1603,29 +1609,29 @@ var $;
|
|
|
1603
1609
|
}
|
|
1604
1610
|
$.$mol_ambient = $mol_ambient;
|
|
1605
1611
|
})($ || ($ = {}));
|
|
1606
|
-
//ambient.
|
|
1612
|
+
//mol/ambient/ambient.ts
|
|
1607
1613
|
;
|
|
1608
1614
|
"use strict";
|
|
1609
1615
|
var $;
|
|
1610
1616
|
(function ($) {
|
|
1611
|
-
|
|
1617
|
+
$mol_test({
|
|
1612
1618
|
'get'() {
|
|
1613
|
-
const proxy =
|
|
1614
|
-
|
|
1619
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1620
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
1615
1621
|
},
|
|
1616
1622
|
'has'() {
|
|
1617
|
-
const proxy =
|
|
1618
|
-
|
|
1623
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1624
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
1619
1625
|
},
|
|
1620
1626
|
'set'() {
|
|
1621
1627
|
const target = { foo: 777 };
|
|
1622
|
-
const proxy =
|
|
1628
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1623
1629
|
proxy.foo = 123;
|
|
1624
|
-
|
|
1630
|
+
$mol_assert_equal(target.foo, 123);
|
|
1625
1631
|
},
|
|
1626
1632
|
'getOwnPropertyDescriptor'() {
|
|
1627
|
-
const proxy =
|
|
1628
|
-
|
|
1633
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1634
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1629
1635
|
value: 777,
|
|
1630
1636
|
writable: true,
|
|
1631
1637
|
enumerable: true,
|
|
@@ -1633,40 +1639,40 @@ var $;
|
|
|
1633
1639
|
});
|
|
1634
1640
|
},
|
|
1635
1641
|
'ownKeys'() {
|
|
1636
|
-
const proxy =
|
|
1637
|
-
|
|
1642
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
1643
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1638
1644
|
},
|
|
1639
1645
|
'getPrototypeOf'() {
|
|
1640
1646
|
class Foo {
|
|
1641
1647
|
}
|
|
1642
|
-
const proxy =
|
|
1643
|
-
|
|
1648
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1649
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1644
1650
|
},
|
|
1645
1651
|
'setPrototypeOf'() {
|
|
1646
1652
|
class Foo {
|
|
1647
1653
|
}
|
|
1648
1654
|
const target = {};
|
|
1649
|
-
const proxy =
|
|
1655
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1650
1656
|
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
1651
|
-
|
|
1657
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
1652
1658
|
},
|
|
1653
1659
|
'instanceof'() {
|
|
1654
1660
|
class Foo {
|
|
1655
1661
|
}
|
|
1656
|
-
const proxy =
|
|
1657
|
-
|
|
1658
|
-
|
|
1662
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1663
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1664
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1659
1665
|
},
|
|
1660
1666
|
'autobind'() {
|
|
1661
1667
|
class Foo {
|
|
1662
1668
|
}
|
|
1663
|
-
const proxy =
|
|
1664
|
-
|
|
1665
|
-
|
|
1669
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1670
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1671
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1666
1672
|
},
|
|
1667
1673
|
});
|
|
1668
1674
|
})($ || ($ = {}));
|
|
1669
|
-
//delegate.test.
|
|
1675
|
+
//mol/delegate/delegate.test.ts
|
|
1670
1676
|
;
|
|
1671
1677
|
"use strict";
|
|
1672
1678
|
var $;
|
|
@@ -1703,7 +1709,7 @@ var $;
|
|
|
1703
1709
|
value: (obj) => instances.has(obj),
|
|
1704
1710
|
});
|
|
1705
1711
|
})($ || ($ = {}));
|
|
1706
|
-
//delegate.
|
|
1712
|
+
//mol/delegate/delegate.ts
|
|
1707
1713
|
;
|
|
1708
1714
|
"use strict";
|
|
1709
1715
|
var $;
|
|
@@ -1715,7 +1721,7 @@ var $;
|
|
|
1715
1721
|
return false;
|
|
1716
1722
|
if (typeof having !== 'object')
|
|
1717
1723
|
return false;
|
|
1718
|
-
if (having instanceof
|
|
1724
|
+
if (having instanceof $mol_delegate)
|
|
1719
1725
|
return false;
|
|
1720
1726
|
if (typeof having['destructor'] !== 'function')
|
|
1721
1727
|
return false;
|
|
@@ -1759,30 +1765,30 @@ var $;
|
|
|
1759
1765
|
}
|
|
1760
1766
|
$.$mol_owning_catch = $mol_owning_catch;
|
|
1761
1767
|
})($ || ($ = {}));
|
|
1762
|
-
//owning.
|
|
1768
|
+
//mol/owning/owning.ts
|
|
1763
1769
|
;
|
|
1764
1770
|
"use strict";
|
|
1765
|
-
//writable.test.
|
|
1771
|
+
//mol/type/writable/writable.test.ts
|
|
1766
1772
|
;
|
|
1767
1773
|
"use strict";
|
|
1768
|
-
//writable.
|
|
1774
|
+
//mol/type/writable/writable.ts
|
|
1769
1775
|
;
|
|
1770
1776
|
"use strict";
|
|
1771
1777
|
var $;
|
|
1772
1778
|
(function ($) {
|
|
1773
1779
|
class $mol_object2 {
|
|
1774
1780
|
static $ = $;
|
|
1775
|
-
[
|
|
1781
|
+
[$mol_ambient_ref] = null;
|
|
1776
1782
|
get $() {
|
|
1777
|
-
if (this[
|
|
1778
|
-
return this[
|
|
1779
|
-
const owner =
|
|
1780
|
-
return this[
|
|
1783
|
+
if (this[$mol_ambient_ref])
|
|
1784
|
+
return this[$mol_ambient_ref];
|
|
1785
|
+
const owner = $mol_owning_get(this);
|
|
1786
|
+
return this[$mol_ambient_ref] = owner?.$ || $mol_object2.$;
|
|
1781
1787
|
}
|
|
1782
1788
|
set $(next) {
|
|
1783
|
-
if (this[
|
|
1784
|
-
|
|
1785
|
-
this[
|
|
1789
|
+
if (this[$mol_ambient_ref])
|
|
1790
|
+
$mol_fail_hidden(new Error('Context already defined'));
|
|
1791
|
+
this[$mol_ambient_ref] = next;
|
|
1786
1792
|
}
|
|
1787
1793
|
static create(init) {
|
|
1788
1794
|
const obj = new this;
|
|
@@ -1808,7 +1814,7 @@ var $;
|
|
|
1808
1814
|
}
|
|
1809
1815
|
$.$mol_object2 = $mol_object2;
|
|
1810
1816
|
})($ || ($ = {}));
|
|
1811
|
-
//object2.
|
|
1817
|
+
//mol/object2/object2.ts
|
|
1812
1818
|
;
|
|
1813
1819
|
"use strict";
|
|
1814
1820
|
var $;
|
|
@@ -1819,7 +1825,7 @@ var $;
|
|
|
1819
1825
|
let warned = false;
|
|
1820
1826
|
descr.value = function $mol_deprecated_wrapper(...args) {
|
|
1821
1827
|
if (!warned) {
|
|
1822
|
-
|
|
1828
|
+
$$.$mol_log3_warn({
|
|
1823
1829
|
place: `${host.constructor.name}::${field}`,
|
|
1824
1830
|
message: `Deprecated`,
|
|
1825
1831
|
hint: message,
|
|
@@ -1832,54 +1838,54 @@ var $;
|
|
|
1832
1838
|
}
|
|
1833
1839
|
$.$mol_deprecated = $mol_deprecated;
|
|
1834
1840
|
})($ || ($ = {}));
|
|
1835
|
-
//deprecated.
|
|
1841
|
+
//mol/deprecated/deprecated.ts
|
|
1836
1842
|
;
|
|
1837
1843
|
"use strict";
|
|
1838
1844
|
var $;
|
|
1839
1845
|
(function ($_1) {
|
|
1840
|
-
$
|
|
1846
|
+
$mol_test({
|
|
1841
1847
|
'tree parsing'() {
|
|
1842
|
-
$
|
|
1843
|
-
$
|
|
1844
|
-
$
|
|
1845
|
-
$
|
|
1846
|
-
$
|
|
1847
|
-
$
|
|
1848
|
-
$
|
|
1849
|
-
$
|
|
1848
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub.length, 2);
|
|
1849
|
+
$mol_assert_equal($mol_tree.fromString("foo\nbar\n").sub[1].type, "bar");
|
|
1850
|
+
$mol_assert_equal($mol_tree.fromString("foo\n\n\n").sub.length, 1);
|
|
1851
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub.length, 2);
|
|
1852
|
+
$mol_assert_equal($mol_tree.fromString("=foo\n\\bar\n").sub[1].data, "bar");
|
|
1853
|
+
$mol_assert_equal($mol_tree.fromString("foo bar \\pol").sub[0].sub[0].sub[0].data, "pol");
|
|
1854
|
+
$mol_assert_equal($mol_tree.fromString("foo bar\n\t\\pol\n\t\\men").sub[0].sub[0].sub[1].data, "men");
|
|
1855
|
+
$mol_assert_equal($mol_tree.fromString('foo bar \\text\n').toString(), 'foo bar \\text\n');
|
|
1850
1856
|
},
|
|
1851
1857
|
'inserting'() {
|
|
1852
|
-
$
|
|
1853
|
-
$
|
|
1854
|
-
$
|
|
1855
|
-
$
|
|
1856
|
-
$
|
|
1857
|
-
$
|
|
1858
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 'a', 'b', 'c').toString(), 'a b \\\n');
|
|
1859
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 'a', 'b', 'c', 'd').toString(), 'a b c \\\n');
|
|
1860
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, 0, 0, 0).toString(), 'a b \\\n');
|
|
1861
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, 0, 0, 0, 0).toString(), 'a b \\\n\t\\\n');
|
|
1862
|
+
$mol_assert_equal($mol_tree.fromString('a b c d').insert(new $mol_tree, null, null, null).toString(), 'a b \\\n');
|
|
1863
|
+
$mol_assert_equal($mol_tree.fromString('a b').insert(new $mol_tree, null, null, null, null).toString(), 'a b \\\n\t\\\n');
|
|
1858
1864
|
},
|
|
1859
1865
|
'fromJSON'() {
|
|
1860
|
-
$
|
|
1861
|
-
$
|
|
1862
|
-
$
|
|
1863
|
-
$
|
|
1864
|
-
$
|
|
1866
|
+
$mol_assert_equal($mol_tree.fromJSON([]).toString(), '/\n');
|
|
1867
|
+
$mol_assert_equal($mol_tree.fromJSON([false, true]).toString(), '/\n\tfalse\n\ttrue\n');
|
|
1868
|
+
$mol_assert_equal($mol_tree.fromJSON([0, 1, 2.3]).toString(), '/\n\t0\n\t1\n\t2.3\n');
|
|
1869
|
+
$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');
|
|
1870
|
+
$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');
|
|
1865
1871
|
},
|
|
1866
1872
|
'toJSON'() {
|
|
1867
|
-
$
|
|
1868
|
-
$
|
|
1869
|
-
$
|
|
1870
|
-
$
|
|
1871
|
-
$
|
|
1873
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n').sub[0]), '[]');
|
|
1874
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\tfalse\n\ttrue\n').sub[0]), '[false,true]');
|
|
1875
|
+
$mol_assert_equal(JSON.stringify($mol_tree.fromString('/\n\t0\n\t1\n\t2.3\n').sub[0]), '[0,1,2.3]');
|
|
1876
|
+
$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"]');
|
|
1877
|
+
$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"}');
|
|
1872
1878
|
},
|
|
1873
1879
|
'hack'() {
|
|
1874
|
-
const res = $
|
|
1880
|
+
const res = $mol_tree.fromString(`foo bar xxx`).hack({
|
|
1875
1881
|
'': (tree, context) => [tree.hack(context)],
|
|
1876
1882
|
'bar': (tree, context) => [tree.hack(context).clone({ type: '777' })],
|
|
1877
1883
|
});
|
|
1878
|
-
$
|
|
1884
|
+
$mol_assert_equal(res.toString(), new $mol_tree({ type: 'foo 777 xxx' }).toString());
|
|
1879
1885
|
},
|
|
1880
1886
|
'errors handling'($) {
|
|
1881
1887
|
const errors = [];
|
|
1882
|
-
class Tree extends $
|
|
1888
|
+
class Tree extends $mol_tree {
|
|
1883
1889
|
static $ = $.$mol_ambient({
|
|
1884
1890
|
$mol_fail: error => errors.push(error.message)
|
|
1885
1891
|
});
|
|
@@ -1888,17 +1894,17 @@ var $;
|
|
|
1888
1894
|
\t \tfoo
|
|
1889
1895
|
bar \\data
|
|
1890
1896
|
`, 'test');
|
|
1891
|
-
$
|
|
1897
|
+
$mol_assert_like(errors, ['Syntax error at test:2\n \tfoo']);
|
|
1892
1898
|
},
|
|
1893
1899
|
});
|
|
1894
1900
|
})($ || ($ = {}));
|
|
1895
|
-
//tree.test.
|
|
1901
|
+
//mol/tree/tree.test.ts
|
|
1896
1902
|
;
|
|
1897
1903
|
"use strict";
|
|
1898
1904
|
var $;
|
|
1899
1905
|
(function ($) {
|
|
1900
1906
|
$.$mol_tree_convert = Symbol('$mol_tree_convert');
|
|
1901
|
-
class $mol_tree extends
|
|
1907
|
+
class $mol_tree extends $mol_object2 {
|
|
1902
1908
|
type;
|
|
1903
1909
|
data;
|
|
1904
1910
|
sub;
|
|
@@ -2211,7 +2217,7 @@ var $;
|
|
|
2211
2217
|
const sub = [].concat(...this.sub.map(child => {
|
|
2212
2218
|
const handle = context[child.type] || context[''];
|
|
2213
2219
|
if (!handle)
|
|
2214
|
-
|
|
2220
|
+
$mol_fail(child.error('Handler not defined'));
|
|
2215
2221
|
return handle(child, context);
|
|
2216
2222
|
}));
|
|
2217
2223
|
return this.clone({ sub });
|
|
@@ -2221,16 +2227,16 @@ var $;
|
|
|
2221
2227
|
}
|
|
2222
2228
|
}
|
|
2223
2229
|
__decorate([
|
|
2224
|
-
|
|
2230
|
+
$mol_deprecated('Use $mol_tree:hack')
|
|
2225
2231
|
], $mol_tree.prototype, "transform", null);
|
|
2226
2232
|
$.$mol_tree = $mol_tree;
|
|
2227
2233
|
})($ || ($ = {}));
|
|
2228
|
-
//tree.
|
|
2234
|
+
//mol/tree/tree.ts
|
|
2229
2235
|
;
|
|
2230
2236
|
"use strict";
|
|
2231
|
-
//equals.test.
|
|
2237
|
+
//mol/type/equals/equals.test.ts
|
|
2232
2238
|
;
|
|
2233
2239
|
"use strict";
|
|
2234
|
-
//equals.
|
|
2240
|
+
//mol/type/equals/equals.ts
|
|
2235
2241
|
|
|
2236
2242
|
//# sourceMappingURL=node.test.js.map
|