mol_wire_lib 1.0.98 → 1.0.101
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 +36 -30
- package/node.deps.json +1 -1
- package/node.esm.js +165 -152
- package/node.esm.js.map +1 -1
- package/node.js +165 -152
- package/node.js.map +1 -1
- package/node.test.js +220 -257
- package/node.test.js.map +1 -1
- package/package.json +5 -3
- package/web.d.ts +36 -30
- package/web.deps.json +1 -1
- package/web.esm.js +165 -152
- package/web.esm.js.map +1 -1
- package/web.js +165 -152
- package/web.js.map +1 -1
- package/web.test.js +55 -105
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -679,84 +679,6 @@ var $;
|
|
|
679
679
|
;
|
|
680
680
|
"use strict";
|
|
681
681
|
var $;
|
|
682
|
-
(function ($) {
|
|
683
|
-
function $mol_guid(length = 8, exists = () => false) {
|
|
684
|
-
for (;;) {
|
|
685
|
-
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
686
|
-
if (exists(id))
|
|
687
|
-
continue;
|
|
688
|
-
return id;
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
$.$mol_guid = $mol_guid;
|
|
692
|
-
})($ || ($ = {}));
|
|
693
|
-
//mol/guid/guid.ts
|
|
694
|
-
;
|
|
695
|
-
"use strict";
|
|
696
|
-
var $;
|
|
697
|
-
(function ($) {
|
|
698
|
-
$.$mol_key_store = new WeakMap();
|
|
699
|
-
function $mol_key(value) {
|
|
700
|
-
if (!value)
|
|
701
|
-
return JSON.stringify(value);
|
|
702
|
-
if (typeof value !== 'object' && typeof value !== 'function')
|
|
703
|
-
return JSON.stringify(value);
|
|
704
|
-
return JSON.stringify(value, (field, value) => {
|
|
705
|
-
if (!value)
|
|
706
|
-
return value;
|
|
707
|
-
if (typeof value !== 'object' && typeof value !== 'function')
|
|
708
|
-
return value;
|
|
709
|
-
if (Array.isArray(value))
|
|
710
|
-
return value;
|
|
711
|
-
const proto = Reflect.getPrototypeOf(value);
|
|
712
|
-
if (!proto)
|
|
713
|
-
return value;
|
|
714
|
-
if (Reflect.getPrototypeOf(proto) === null)
|
|
715
|
-
return value;
|
|
716
|
-
if ('toJSON' in value)
|
|
717
|
-
return value;
|
|
718
|
-
if (value instanceof RegExp)
|
|
719
|
-
return value.toString();
|
|
720
|
-
let key = $.$mol_key_store.get(value);
|
|
721
|
-
if (key)
|
|
722
|
-
return key;
|
|
723
|
-
key = $mol_guid();
|
|
724
|
-
$.$mol_key_store.set(value, key);
|
|
725
|
-
return key;
|
|
726
|
-
});
|
|
727
|
-
}
|
|
728
|
-
$.$mol_key = $mol_key;
|
|
729
|
-
})($ || ($ = {}));
|
|
730
|
-
//mol/key/key.ts
|
|
731
|
-
;
|
|
732
|
-
"use strict";
|
|
733
|
-
var $;
|
|
734
|
-
(function ($) {
|
|
735
|
-
function $mol_wire_method(host, field, descr) {
|
|
736
|
-
if (!descr)
|
|
737
|
-
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
738
|
-
const orig = descr?.value ?? host[field];
|
|
739
|
-
const sup = Reflect.getPrototypeOf(host);
|
|
740
|
-
if (typeof sup[field] === 'function') {
|
|
741
|
-
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
742
|
-
}
|
|
743
|
-
const temp = $mol_wire_fiber_temp.getter(orig);
|
|
744
|
-
const value = function (...args) {
|
|
745
|
-
const fiber = temp(this ?? null, args);
|
|
746
|
-
return fiber.sync();
|
|
747
|
-
};
|
|
748
|
-
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
749
|
-
Object.assign(value, { orig });
|
|
750
|
-
const descr2 = { ...descr, value };
|
|
751
|
-
Reflect.defineProperty(host, field, descr2);
|
|
752
|
-
return descr2;
|
|
753
|
-
}
|
|
754
|
-
$.$mol_wire_method = $mol_wire_method;
|
|
755
|
-
})($ || ($ = {}));
|
|
756
|
-
//mol/wire/method/method.ts
|
|
757
|
-
;
|
|
758
|
-
"use strict";
|
|
759
|
-
var $;
|
|
760
682
|
(function ($) {
|
|
761
683
|
const handled = new WeakSet();
|
|
762
684
|
class $mol_wire_fiber extends $mol_wire_pub_sub {
|
|
@@ -970,6 +892,40 @@ var $;
|
|
|
970
892
|
}
|
|
971
893
|
}
|
|
972
894
|
$.$mol_wire_fiber = $mol_wire_fiber;
|
|
895
|
+
})($ || ($ = {}));
|
|
896
|
+
//mol/wire/fiber/fiber.ts
|
|
897
|
+
;
|
|
898
|
+
"use strict";
|
|
899
|
+
var $;
|
|
900
|
+
(function ($) {
|
|
901
|
+
function $mol_wire_probe(task, next) {
|
|
902
|
+
const warm = $mol_wire_fiber.warm;
|
|
903
|
+
try {
|
|
904
|
+
$mol_wire_fiber.warm = false;
|
|
905
|
+
return task();
|
|
906
|
+
}
|
|
907
|
+
finally {
|
|
908
|
+
$mol_wire_fiber.warm = warm;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
$.$mol_wire_probe = $mol_wire_probe;
|
|
912
|
+
})($ || ($ = {}));
|
|
913
|
+
//mol/wire/probe/probe.ts
|
|
914
|
+
;
|
|
915
|
+
"use strict";
|
|
916
|
+
var $;
|
|
917
|
+
(function ($) {
|
|
918
|
+
function $mol_wire_solid() {
|
|
919
|
+
$mol_wire_auto().reap = nothing;
|
|
920
|
+
}
|
|
921
|
+
$.$mol_wire_solid = $mol_wire_solid;
|
|
922
|
+
const nothing = () => { };
|
|
923
|
+
})($ || ($ = {}));
|
|
924
|
+
//mol/wire/solid/solid.ts
|
|
925
|
+
;
|
|
926
|
+
"use strict";
|
|
927
|
+
var $;
|
|
928
|
+
(function ($) {
|
|
973
929
|
class $mol_wire_fiber_temp extends $mol_wire_fiber {
|
|
974
930
|
static getter(task) {
|
|
975
931
|
return function $mol_wire_fiber_temp_get(host, args) {
|
|
@@ -989,10 +945,139 @@ var $;
|
|
|
989
945
|
};
|
|
990
946
|
}
|
|
991
947
|
complete() {
|
|
992
|
-
this.
|
|
948
|
+
if (this.sub_empty)
|
|
949
|
+
this.destructor();
|
|
993
950
|
}
|
|
994
951
|
}
|
|
995
952
|
$.$mol_wire_fiber_temp = $mol_wire_fiber_temp;
|
|
953
|
+
})($ || ($ = {}));
|
|
954
|
+
//mol/wire/fiber/temp/temp.ts
|
|
955
|
+
;
|
|
956
|
+
"use strict";
|
|
957
|
+
var $;
|
|
958
|
+
(function ($) {
|
|
959
|
+
function $mol_wire_sync(obj) {
|
|
960
|
+
return new Proxy(obj, {
|
|
961
|
+
get(obj, field) {
|
|
962
|
+
const val = obj[field];
|
|
963
|
+
if (typeof val !== 'function')
|
|
964
|
+
return val;
|
|
965
|
+
const temp = $mol_wire_fiber_temp.getter(val);
|
|
966
|
+
return function $mol_wire_sync(...args) {
|
|
967
|
+
const fiber = temp(obj, args);
|
|
968
|
+
return fiber.sync();
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
$.$mol_wire_sync = $mol_wire_sync;
|
|
974
|
+
})($ || ($ = {}));
|
|
975
|
+
//mol/wire/sync/sync.ts
|
|
976
|
+
;
|
|
977
|
+
"use strict";
|
|
978
|
+
var $;
|
|
979
|
+
(function ($) {
|
|
980
|
+
function $mol_wire_async(obj) {
|
|
981
|
+
return new Proxy(obj, {
|
|
982
|
+
get(obj, field) {
|
|
983
|
+
const val = obj[field];
|
|
984
|
+
if (typeof val !== 'function')
|
|
985
|
+
return val;
|
|
986
|
+
let fiber;
|
|
987
|
+
const temp = $mol_wire_fiber_temp.getter(val);
|
|
988
|
+
return function $mol_wire_async(...args) {
|
|
989
|
+
fiber?.destructor();
|
|
990
|
+
fiber = temp(obj, args);
|
|
991
|
+
return fiber.async();
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
$.$mol_wire_async = $mol_wire_async;
|
|
997
|
+
})($ || ($ = {}));
|
|
998
|
+
//mol/wire/async/async.ts
|
|
999
|
+
;
|
|
1000
|
+
"use strict";
|
|
1001
|
+
var $;
|
|
1002
|
+
(function ($) {
|
|
1003
|
+
function $mol_guid(length = 8, exists = () => false) {
|
|
1004
|
+
for (;;) {
|
|
1005
|
+
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
1006
|
+
if (exists(id))
|
|
1007
|
+
continue;
|
|
1008
|
+
return id;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
$.$mol_guid = $mol_guid;
|
|
1012
|
+
})($ || ($ = {}));
|
|
1013
|
+
//mol/guid/guid.ts
|
|
1014
|
+
;
|
|
1015
|
+
"use strict";
|
|
1016
|
+
var $;
|
|
1017
|
+
(function ($) {
|
|
1018
|
+
$.$mol_key_store = new WeakMap();
|
|
1019
|
+
function $mol_key(value) {
|
|
1020
|
+
if (!value)
|
|
1021
|
+
return JSON.stringify(value);
|
|
1022
|
+
if (typeof value !== 'object' && typeof value !== 'function')
|
|
1023
|
+
return JSON.stringify(value);
|
|
1024
|
+
return JSON.stringify(value, (field, value) => {
|
|
1025
|
+
if (!value)
|
|
1026
|
+
return value;
|
|
1027
|
+
if (typeof value !== 'object' && typeof value !== 'function')
|
|
1028
|
+
return value;
|
|
1029
|
+
if (Array.isArray(value))
|
|
1030
|
+
return value;
|
|
1031
|
+
const proto = Reflect.getPrototypeOf(value);
|
|
1032
|
+
if (!proto)
|
|
1033
|
+
return value;
|
|
1034
|
+
if (Reflect.getPrototypeOf(proto) === null)
|
|
1035
|
+
return value;
|
|
1036
|
+
if ('toJSON' in value)
|
|
1037
|
+
return value;
|
|
1038
|
+
if (value instanceof RegExp)
|
|
1039
|
+
return value.toString();
|
|
1040
|
+
let key = $.$mol_key_store.get(value);
|
|
1041
|
+
if (key)
|
|
1042
|
+
return key;
|
|
1043
|
+
key = $mol_guid();
|
|
1044
|
+
$.$mol_key_store.set(value, key);
|
|
1045
|
+
return key;
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
$.$mol_key = $mol_key;
|
|
1049
|
+
})($ || ($ = {}));
|
|
1050
|
+
//mol/key/key.ts
|
|
1051
|
+
;
|
|
1052
|
+
"use strict";
|
|
1053
|
+
var $;
|
|
1054
|
+
(function ($) {
|
|
1055
|
+
function $mol_wire_method(host, field, descr) {
|
|
1056
|
+
if (!descr)
|
|
1057
|
+
descr = Reflect.getOwnPropertyDescriptor(host, field);
|
|
1058
|
+
const orig = descr?.value ?? host[field];
|
|
1059
|
+
const sup = Reflect.getPrototypeOf(host);
|
|
1060
|
+
if (typeof sup[field] === 'function') {
|
|
1061
|
+
Object.defineProperty(orig, 'name', { value: sup[field].name });
|
|
1062
|
+
}
|
|
1063
|
+
const temp = $mol_wire_fiber_temp.getter(orig);
|
|
1064
|
+
const value = function (...args) {
|
|
1065
|
+
const fiber = temp(this ?? null, args);
|
|
1066
|
+
return fiber.sync();
|
|
1067
|
+
};
|
|
1068
|
+
Object.defineProperty(value, 'name', { value: orig.name + ' ' });
|
|
1069
|
+
Object.assign(value, { orig });
|
|
1070
|
+
const descr2 = { ...descr, value };
|
|
1071
|
+
Reflect.defineProperty(host, field, descr2);
|
|
1072
|
+
return descr2;
|
|
1073
|
+
}
|
|
1074
|
+
$.$mol_wire_method = $mol_wire_method;
|
|
1075
|
+
})($ || ($ = {}));
|
|
1076
|
+
//mol/wire/method/method.ts
|
|
1077
|
+
;
|
|
1078
|
+
"use strict";
|
|
1079
|
+
var $;
|
|
1080
|
+
(function ($) {
|
|
996
1081
|
class $mol_wire_fiber_persist extends $mol_wire_fiber {
|
|
997
1082
|
static getter(task, keys) {
|
|
998
1083
|
const field = task.name + '()';
|
|
@@ -1065,79 +1150,7 @@ var $;
|
|
|
1065
1150
|
], $mol_wire_fiber_persist.prototype, "once", null);
|
|
1066
1151
|
$.$mol_wire_fiber_persist = $mol_wire_fiber_persist;
|
|
1067
1152
|
})($ || ($ = {}));
|
|
1068
|
-
//mol/wire/fiber/
|
|
1069
|
-
;
|
|
1070
|
-
"use strict";
|
|
1071
|
-
var $;
|
|
1072
|
-
(function ($) {
|
|
1073
|
-
function $mol_wire_probe(task, next) {
|
|
1074
|
-
const warm = $mol_wire_fiber.warm;
|
|
1075
|
-
try {
|
|
1076
|
-
$mol_wire_fiber.warm = false;
|
|
1077
|
-
return task();
|
|
1078
|
-
}
|
|
1079
|
-
finally {
|
|
1080
|
-
$mol_wire_fiber.warm = warm;
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
$.$mol_wire_probe = $mol_wire_probe;
|
|
1084
|
-
})($ || ($ = {}));
|
|
1085
|
-
//mol/wire/probe/probe.ts
|
|
1086
|
-
;
|
|
1087
|
-
"use strict";
|
|
1088
|
-
var $;
|
|
1089
|
-
(function ($) {
|
|
1090
|
-
function $mol_wire_solid() {
|
|
1091
|
-
$mol_wire_auto().reap = nothing;
|
|
1092
|
-
}
|
|
1093
|
-
$.$mol_wire_solid = $mol_wire_solid;
|
|
1094
|
-
const nothing = () => { };
|
|
1095
|
-
})($ || ($ = {}));
|
|
1096
|
-
//mol/wire/solid/solid.ts
|
|
1097
|
-
;
|
|
1098
|
-
"use strict";
|
|
1099
|
-
var $;
|
|
1100
|
-
(function ($) {
|
|
1101
|
-
function $mol_wire_sync(obj) {
|
|
1102
|
-
return new Proxy(obj, {
|
|
1103
|
-
get(obj, field) {
|
|
1104
|
-
const val = obj[field];
|
|
1105
|
-
if (typeof val !== 'function')
|
|
1106
|
-
return val;
|
|
1107
|
-
const temp = $mol_wire_fiber_temp.getter(val);
|
|
1108
|
-
return function $mol_wire_sync(...args) {
|
|
1109
|
-
const fiber = temp(obj, args);
|
|
1110
|
-
return fiber.sync();
|
|
1111
|
-
};
|
|
1112
|
-
}
|
|
1113
|
-
});
|
|
1114
|
-
}
|
|
1115
|
-
$.$mol_wire_sync = $mol_wire_sync;
|
|
1116
|
-
})($ || ($ = {}));
|
|
1117
|
-
//mol/wire/sync/sync.ts
|
|
1118
|
-
;
|
|
1119
|
-
"use strict";
|
|
1120
|
-
var $;
|
|
1121
|
-
(function ($) {
|
|
1122
|
-
function $mol_wire_async(obj) {
|
|
1123
|
-
return new Proxy(obj, {
|
|
1124
|
-
get(obj, field) {
|
|
1125
|
-
const val = obj[field];
|
|
1126
|
-
if (typeof val !== 'function')
|
|
1127
|
-
return val;
|
|
1128
|
-
let fiber;
|
|
1129
|
-
const temp = $mol_wire_fiber_temp.getter(val);
|
|
1130
|
-
return function $mol_wire_async(...args) {
|
|
1131
|
-
fiber?.destructor();
|
|
1132
|
-
fiber = temp(obj, args);
|
|
1133
|
-
return fiber.async();
|
|
1134
|
-
};
|
|
1135
|
-
}
|
|
1136
|
-
});
|
|
1137
|
-
}
|
|
1138
|
-
$.$mol_wire_async = $mol_wire_async;
|
|
1139
|
-
})($ || ($ = {}));
|
|
1140
|
-
//mol/wire/async/async.ts
|
|
1153
|
+
//mol/wire/fiber/persist/persist.ts
|
|
1141
1154
|
;
|
|
1142
1155
|
"use strict";
|
|
1143
1156
|
var $;
|
|
@@ -2338,61 +2351,6 @@ var $;
|
|
|
2338
2351
|
;
|
|
2339
2352
|
"use strict";
|
|
2340
2353
|
var $;
|
|
2341
|
-
(function ($) {
|
|
2342
|
-
$mol_test({
|
|
2343
|
-
'Primitives'() {
|
|
2344
|
-
$mol_assert_equal($mol_key(null), 'null');
|
|
2345
|
-
$mol_assert_equal($mol_key(false), 'false');
|
|
2346
|
-
$mol_assert_equal($mol_key(true), 'true');
|
|
2347
|
-
$mol_assert_equal($mol_key(0), '0');
|
|
2348
|
-
$mol_assert_equal($mol_key(''), '""');
|
|
2349
|
-
},
|
|
2350
|
-
'Array & POJO'() {
|
|
2351
|
-
$mol_assert_equal($mol_key([null]), '[null]');
|
|
2352
|
-
$mol_assert_equal($mol_key({ foo: 0 }), '{"foo":0}');
|
|
2353
|
-
$mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
|
|
2354
|
-
},
|
|
2355
|
-
'Function'() {
|
|
2356
|
-
const func = () => { };
|
|
2357
|
-
$mol_assert_equal($mol_key(func), $mol_key(func));
|
|
2358
|
-
$mol_assert_unique($mol_key(func), $mol_key(() => { }));
|
|
2359
|
-
},
|
|
2360
|
-
'Objects'() {
|
|
2361
|
-
class User {
|
|
2362
|
-
}
|
|
2363
|
-
const jin = new User();
|
|
2364
|
-
$mol_assert_equal($mol_key(jin), $mol_key(jin));
|
|
2365
|
-
$mol_assert_unique($mol_key(jin), $mol_key(new User()));
|
|
2366
|
-
},
|
|
2367
|
-
'Elements'() {
|
|
2368
|
-
const foo = $mol_jsx("div", null, "bar");
|
|
2369
|
-
$mol_assert_equal($mol_key(foo), $mol_key(foo));
|
|
2370
|
-
$mol_assert_unique($mol_key(foo), $mol_key($mol_jsx("div", null, "bar")));
|
|
2371
|
-
},
|
|
2372
|
-
'Custom JSON representation'() {
|
|
2373
|
-
class User {
|
|
2374
|
-
name;
|
|
2375
|
-
age;
|
|
2376
|
-
constructor(name, age) {
|
|
2377
|
-
this.name = name;
|
|
2378
|
-
this.age = age;
|
|
2379
|
-
}
|
|
2380
|
-
toJSON() { return { name: this.name }; }
|
|
2381
|
-
}
|
|
2382
|
-
$mol_assert_equal($mol_key(new User('jin', 18)), '{"name":"jin"}');
|
|
2383
|
-
},
|
|
2384
|
-
'Special native classes'() {
|
|
2385
|
-
$mol_assert_equal($mol_key(new Date('xyz')), 'null');
|
|
2386
|
-
$mol_assert_equal($mol_key(new Date('2001-01-02T03:04:05.678Z')), '"2001-01-02T03:04:05.678Z"');
|
|
2387
|
-
$mol_assert_equal($mol_key(/./), '"/./"');
|
|
2388
|
-
$mol_assert_equal($mol_key(/\./gimsu), '"/\\\\./gimsu"');
|
|
2389
|
-
},
|
|
2390
|
-
});
|
|
2391
|
-
})($ || ($ = {}));
|
|
2392
|
-
//mol/key/key.test.tsx
|
|
2393
|
-
;
|
|
2394
|
-
"use strict";
|
|
2395
|
-
var $;
|
|
2396
2354
|
(function ($) {
|
|
2397
2355
|
$mol_test({
|
|
2398
2356
|
'Sync execution'() {
|
|
@@ -2475,6 +2433,61 @@ var $;
|
|
|
2475
2433
|
;
|
|
2476
2434
|
"use strict";
|
|
2477
2435
|
var $;
|
|
2436
|
+
(function ($) {
|
|
2437
|
+
$mol_test({
|
|
2438
|
+
'Primitives'() {
|
|
2439
|
+
$mol_assert_equal($mol_key(null), 'null');
|
|
2440
|
+
$mol_assert_equal($mol_key(false), 'false');
|
|
2441
|
+
$mol_assert_equal($mol_key(true), 'true');
|
|
2442
|
+
$mol_assert_equal($mol_key(0), '0');
|
|
2443
|
+
$mol_assert_equal($mol_key(''), '""');
|
|
2444
|
+
},
|
|
2445
|
+
'Array & POJO'() {
|
|
2446
|
+
$mol_assert_equal($mol_key([null]), '[null]');
|
|
2447
|
+
$mol_assert_equal($mol_key({ foo: 0 }), '{"foo":0}');
|
|
2448
|
+
$mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
|
|
2449
|
+
},
|
|
2450
|
+
'Function'() {
|
|
2451
|
+
const func = () => { };
|
|
2452
|
+
$mol_assert_equal($mol_key(func), $mol_key(func));
|
|
2453
|
+
$mol_assert_unique($mol_key(func), $mol_key(() => { }));
|
|
2454
|
+
},
|
|
2455
|
+
'Objects'() {
|
|
2456
|
+
class User {
|
|
2457
|
+
}
|
|
2458
|
+
const jin = new User();
|
|
2459
|
+
$mol_assert_equal($mol_key(jin), $mol_key(jin));
|
|
2460
|
+
$mol_assert_unique($mol_key(jin), $mol_key(new User()));
|
|
2461
|
+
},
|
|
2462
|
+
'Elements'() {
|
|
2463
|
+
const foo = $mol_jsx("div", null, "bar");
|
|
2464
|
+
$mol_assert_equal($mol_key(foo), $mol_key(foo));
|
|
2465
|
+
$mol_assert_unique($mol_key(foo), $mol_key($mol_jsx("div", null, "bar")));
|
|
2466
|
+
},
|
|
2467
|
+
'Custom JSON representation'() {
|
|
2468
|
+
class User {
|
|
2469
|
+
name;
|
|
2470
|
+
age;
|
|
2471
|
+
constructor(name, age) {
|
|
2472
|
+
this.name = name;
|
|
2473
|
+
this.age = age;
|
|
2474
|
+
}
|
|
2475
|
+
toJSON() { return { name: this.name }; }
|
|
2476
|
+
}
|
|
2477
|
+
$mol_assert_equal($mol_key(new User('jin', 18)), '{"name":"jin"}');
|
|
2478
|
+
},
|
|
2479
|
+
'Special native classes'() {
|
|
2480
|
+
$mol_assert_equal($mol_key(new Date('xyz')), 'null');
|
|
2481
|
+
$mol_assert_equal($mol_key(new Date('2001-01-02T03:04:05.678Z')), '"2001-01-02T03:04:05.678Z"');
|
|
2482
|
+
$mol_assert_equal($mol_key(/./), '"/./"');
|
|
2483
|
+
$mol_assert_equal($mol_key(/\./gimsu), '"/\\\\./gimsu"');
|
|
2484
|
+
},
|
|
2485
|
+
});
|
|
2486
|
+
})($ || ($ = {}));
|
|
2487
|
+
//mol/key/key.test.tsx
|
|
2488
|
+
;
|
|
2489
|
+
"use strict";
|
|
2490
|
+
var $;
|
|
2478
2491
|
(function ($_1) {
|
|
2479
2492
|
$mol_test({
|
|
2480
2493
|
'Cached channel'($) {
|
|
@@ -2885,29 +2898,6 @@ var $;
|
|
|
2885
2898
|
$mol_wire_fiber.sync();
|
|
2886
2899
|
$mol_assert_equal(await $mol_wire_async(App).result(), 1);
|
|
2887
2900
|
},
|
|
2888
|
-
'Forget sub fibers on complete'($) {
|
|
2889
|
-
class App extends $mol_object2 {
|
|
2890
|
-
static get $() { return $; }
|
|
2891
|
-
static counter = 0;
|
|
2892
|
-
static count() { return this.counter++; }
|
|
2893
|
-
static data(next = 1) { return next; }
|
|
2894
|
-
static result() {
|
|
2895
|
-
return this.count() + this.data();
|
|
2896
|
-
}
|
|
2897
|
-
}
|
|
2898
|
-
__decorate([
|
|
2899
|
-
$mol_wire_method
|
|
2900
|
-
], App, "count", null);
|
|
2901
|
-
__decorate([
|
|
2902
|
-
$mol_wire_mem(0)
|
|
2903
|
-
], App, "data", null);
|
|
2904
|
-
__decorate([
|
|
2905
|
-
$mol_wire_mem(0)
|
|
2906
|
-
], App, "result", null);
|
|
2907
|
-
$mol_assert_equal(App.result(), 1);
|
|
2908
|
-
App.data(2);
|
|
2909
|
-
$mol_assert_equal(App.result(), 3);
|
|
2910
|
-
},
|
|
2911
2901
|
'Memoize by single simple key'($) {
|
|
2912
2902
|
class Team extends $mol_object2 {
|
|
2913
2903
|
static $ = $;
|
|
@@ -3021,33 +3011,6 @@ var $;
|
|
|
3021
3011
|
$mol_assert_equal(Fib.value(4), 8);
|
|
3022
3012
|
$mol_assert_equal(Fib.sums, 6);
|
|
3023
3013
|
},
|
|
3024
|
-
'Unsubscribe from temp pubs on complete'($) {
|
|
3025
|
-
class Random extends $mol_object2 {
|
|
3026
|
-
static $ = $;
|
|
3027
|
-
static seed() {
|
|
3028
|
-
return Math.random();
|
|
3029
|
-
}
|
|
3030
|
-
static resets(next) {
|
|
3031
|
-
return Math.random();
|
|
3032
|
-
}
|
|
3033
|
-
static value() {
|
|
3034
|
-
this.resets();
|
|
3035
|
-
return this.seed();
|
|
3036
|
-
}
|
|
3037
|
-
}
|
|
3038
|
-
__decorate([
|
|
3039
|
-
$mol_wire_method
|
|
3040
|
-
], Random, "seed", null);
|
|
3041
|
-
__decorate([
|
|
3042
|
-
$mol_wire_mem(0)
|
|
3043
|
-
], Random, "resets", null);
|
|
3044
|
-
__decorate([
|
|
3045
|
-
$mol_wire_mem(0)
|
|
3046
|
-
], Random, "value", null);
|
|
3047
|
-
const first = Random.value();
|
|
3048
|
-
Random.resets(null);
|
|
3049
|
-
$mol_assert_unique(Random.value(), first);
|
|
3050
|
-
},
|
|
3051
3014
|
});
|
|
3052
3015
|
})($ || ($ = {}));
|
|
3053
3016
|
//mol/wire/mem/mem.test.ts
|