mol_jsx_lib 0.0.54 → 0.0.57
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 +100 -0
- package/node.deps.json +1 -1
- package/node.esm.js +461 -2
- package/node.esm.js.map +1 -1
- package/node.js +461 -2
- package/node.js.map +1 -1
- package/node.test.js +971 -368
- package/node.test.js.map +1 -1
- package/package.json +19 -2
- package/web.d.ts +141 -0
- package/web.deps.json +1 -1
- package/web.esm.js +538 -2
- package/web.esm.js.map +1 -1
- package/web.js +538 -2
- package/web.js.map +1 -1
- package/web.test.js +309 -242
- package/web.test.js.map +1 -1
package/web.test.js
CHANGED
|
@@ -238,6 +238,20 @@ var $;
|
|
|
238
238
|
//mol/assert/assert.ts
|
|
239
239
|
;
|
|
240
240
|
"use strict";
|
|
241
|
+
var $;
|
|
242
|
+
(function ($_1) {
|
|
243
|
+
$mol_test({
|
|
244
|
+
'FQN of anon function'($) {
|
|
245
|
+
const $$ = Object.assign($, { $mol_func_name_test: (() => () => { })() });
|
|
246
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '');
|
|
247
|
+
$mol_assert_equal($$.$mol_func_name($$.$mol_func_name_test), '$mol_func_name_test');
|
|
248
|
+
$mol_assert_equal($$.$mol_func_name_test.name, '$mol_func_name_test');
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
})($ || ($ = {}));
|
|
252
|
+
//mol/func/name/name.test.ts
|
|
253
|
+
;
|
|
254
|
+
"use strict";
|
|
241
255
|
//mol/type/error/error.ts
|
|
242
256
|
;
|
|
243
257
|
"use strict";
|
|
@@ -256,36 +270,9 @@ var $;
|
|
|
256
270
|
//mol/type/partial/deep/deep.test.ts
|
|
257
271
|
;
|
|
258
272
|
"use strict";
|
|
259
|
-
var $;
|
|
260
|
-
(function ($) {
|
|
261
|
-
function $mol_log3_area_lazy(event) {
|
|
262
|
-
const self = this;
|
|
263
|
-
const stack = self.$mol_log3_stack;
|
|
264
|
-
const deep = stack.length;
|
|
265
|
-
let logged = false;
|
|
266
|
-
stack.push(() => {
|
|
267
|
-
logged = true;
|
|
268
|
-
self.$mol_log3_area.call(self, event);
|
|
269
|
-
});
|
|
270
|
-
return () => {
|
|
271
|
-
if (logged)
|
|
272
|
-
self.console.groupEnd();
|
|
273
|
-
if (stack.length > deep)
|
|
274
|
-
stack.length = deep;
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
$.$mol_log3_area_lazy = $mol_log3_area_lazy;
|
|
278
|
-
$.$mol_log3_stack = [];
|
|
279
|
-
})($ || ($ = {}));
|
|
280
|
-
//mol/log3/log3.ts
|
|
281
|
-
;
|
|
282
|
-
"use strict";
|
|
283
273
|
//mol/type/keys/extract/extract.test.ts
|
|
284
274
|
;
|
|
285
275
|
"use strict";
|
|
286
|
-
//mol/type/keys/extract/extract.ts
|
|
287
|
-
;
|
|
288
|
-
"use strict";
|
|
289
276
|
var $;
|
|
290
277
|
(function ($_1) {
|
|
291
278
|
$mol_test_mocks.push($ => {
|
|
@@ -301,35 +288,6 @@ var $;
|
|
|
301
288
|
;
|
|
302
289
|
"use strict";
|
|
303
290
|
var $;
|
|
304
|
-
(function ($) {
|
|
305
|
-
function $mol_log3_web_make(level, color) {
|
|
306
|
-
return function $mol_log3_logger(event) {
|
|
307
|
-
const pending = this.$mol_log3_stack.pop();
|
|
308
|
-
if (pending)
|
|
309
|
-
pending();
|
|
310
|
-
let tpl = '%c';
|
|
311
|
-
const chunks = Object.values(event);
|
|
312
|
-
for (let i = 0; i < chunks.length; ++i) {
|
|
313
|
-
tpl += (typeof chunks[i] === 'string') ? ' ⦙ %s' : ' ⦙ %o';
|
|
314
|
-
}
|
|
315
|
-
const style = `color:${color};font-weight:bolder`;
|
|
316
|
-
this.console[level](tpl, style, ...chunks);
|
|
317
|
-
const self = this;
|
|
318
|
-
return () => self.console.groupEnd();
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
$.$mol_log3_web_make = $mol_log3_web_make;
|
|
322
|
-
$.$mol_log3_come = $mol_log3_web_make('info', 'royalblue');
|
|
323
|
-
$.$mol_log3_done = $mol_log3_web_make('info', 'forestgreen');
|
|
324
|
-
$.$mol_log3_fail = $mol_log3_web_make('error', 'orangered');
|
|
325
|
-
$.$mol_log3_warn = $mol_log3_web_make('warn', 'goldenrod');
|
|
326
|
-
$.$mol_log3_rise = $mol_log3_web_make('log', 'magenta');
|
|
327
|
-
$.$mol_log3_area = $mol_log3_web_make('group', 'cyan');
|
|
328
|
-
})($ || ($ = {}));
|
|
329
|
-
//mol/log3/log3.web.ts
|
|
330
|
-
;
|
|
331
|
-
"use strict";
|
|
332
|
-
var $;
|
|
333
291
|
(function ($) {
|
|
334
292
|
$mol_test({
|
|
335
293
|
'Make empty div'() {
|
|
@@ -388,7 +346,29 @@ var $;
|
|
|
388
346
|
$mol_jsx("span", { id: "/bar" }),
|
|
389
347
|
$mol_jsx("span", { id: "/bar" }));
|
|
390
348
|
};
|
|
391
|
-
$mol_assert_fail(() => $mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/bar"');
|
|
349
|
+
$mol_assert_fail(() => $mol_jsx(App, { id: "/foo" }), 'JSX already has tag with id "/foo/bar"');
|
|
350
|
+
},
|
|
351
|
+
'Owner based guid generationn'() {
|
|
352
|
+
const Foo = () => {
|
|
353
|
+
return $mol_jsx("div", null,
|
|
354
|
+
$mol_jsx(Bar, { id: "/bar", icon: () => $mol_jsx("img", { id: "/icon" }) }));
|
|
355
|
+
};
|
|
356
|
+
const Bar = (props) => {
|
|
357
|
+
return $mol_jsx("span", null, props.icon());
|
|
358
|
+
};
|
|
359
|
+
const dom = $mol_jsx(Foo, { id: "/foo" });
|
|
360
|
+
$mol_assert_equal(dom.outerHTML, '<div id="/foo"><span id="/foo/bar"><img id="/foo/icon"></span></div>');
|
|
361
|
+
},
|
|
362
|
+
'Fail on same ids from different caller'() {
|
|
363
|
+
const Foo = () => {
|
|
364
|
+
return $mol_jsx("div", null,
|
|
365
|
+
$mol_jsx("img", { id: "/icon" }),
|
|
366
|
+
$mol_jsx(Bar, { id: "/bar", icon: () => $mol_jsx("img", { id: "/icon" }) }));
|
|
367
|
+
};
|
|
368
|
+
const Bar = (props) => {
|
|
369
|
+
return $mol_jsx("span", null, props.icon());
|
|
370
|
+
};
|
|
371
|
+
$mol_assert_fail(() => $mol_jsx(Foo, { id: "/foo" }), 'JSX already has tag with id "/foo/icon"');
|
|
392
372
|
},
|
|
393
373
|
});
|
|
394
374
|
})($ || ($ = {}));
|
|
@@ -772,51 +752,6 @@ var $;
|
|
|
772
752
|
;
|
|
773
753
|
"use strict";
|
|
774
754
|
var $;
|
|
775
|
-
(function ($) {
|
|
776
|
-
function $mol_wire_sync(obj) {
|
|
777
|
-
return new Proxy(obj, {
|
|
778
|
-
get(obj, field) {
|
|
779
|
-
const val = obj[field];
|
|
780
|
-
if (typeof val !== 'function')
|
|
781
|
-
return val;
|
|
782
|
-
const temp = $mol_wire_task.getter(val);
|
|
783
|
-
return function $mol_wire_sync(...args) {
|
|
784
|
-
const fiber = temp(obj, args);
|
|
785
|
-
return fiber.sync();
|
|
786
|
-
};
|
|
787
|
-
},
|
|
788
|
-
apply(obj, self, args) {
|
|
789
|
-
const temp = $mol_wire_task.getter(obj);
|
|
790
|
-
const fiber = temp(self, args);
|
|
791
|
-
return fiber.sync();
|
|
792
|
-
},
|
|
793
|
-
});
|
|
794
|
-
}
|
|
795
|
-
$.$mol_wire_sync = $mol_wire_sync;
|
|
796
|
-
})($ || ($ = {}));
|
|
797
|
-
//mol/wire/sync/sync.ts
|
|
798
|
-
;
|
|
799
|
-
"use strict";
|
|
800
|
-
var $;
|
|
801
|
-
(function ($) {
|
|
802
|
-
function $mol_promise() {
|
|
803
|
-
let done;
|
|
804
|
-
let fail;
|
|
805
|
-
const promise = new Promise((d, f) => {
|
|
806
|
-
done = d;
|
|
807
|
-
fail = f;
|
|
808
|
-
});
|
|
809
|
-
return Object.assign(promise, {
|
|
810
|
-
done,
|
|
811
|
-
fail,
|
|
812
|
-
});
|
|
813
|
-
}
|
|
814
|
-
$.$mol_promise = $mol_promise;
|
|
815
|
-
})($ || ($ = {}));
|
|
816
|
-
//mol/promise/promise.ts
|
|
817
|
-
;
|
|
818
|
-
"use strict";
|
|
819
|
-
var $;
|
|
820
755
|
(function ($_1) {
|
|
821
756
|
$mol_test_mocks.push($ => {
|
|
822
757
|
$.$mol_after_timeout = $mol_after_mock_timeout;
|
|
@@ -826,45 +761,6 @@ var $;
|
|
|
826
761
|
;
|
|
827
762
|
"use strict";
|
|
828
763
|
var $;
|
|
829
|
-
(function ($) {
|
|
830
|
-
class $mol_after_timeout extends $mol_object2 {
|
|
831
|
-
delay;
|
|
832
|
-
task;
|
|
833
|
-
id;
|
|
834
|
-
constructor(delay, task) {
|
|
835
|
-
super();
|
|
836
|
-
this.delay = delay;
|
|
837
|
-
this.task = task;
|
|
838
|
-
this.id = setTimeout(task, delay);
|
|
839
|
-
}
|
|
840
|
-
destructor() {
|
|
841
|
-
clearTimeout(this.id);
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
$.$mol_after_timeout = $mol_after_timeout;
|
|
845
|
-
})($ || ($ = {}));
|
|
846
|
-
//mol/after/timeout/timeout.ts
|
|
847
|
-
;
|
|
848
|
-
"use strict";
|
|
849
|
-
var $;
|
|
850
|
-
(function ($) {
|
|
851
|
-
function $mol_wait_timeout_async(timeout) {
|
|
852
|
-
const promise = $mol_promise();
|
|
853
|
-
const task = new this.$mol_after_timeout(timeout, () => promise.done());
|
|
854
|
-
return Object.assign(promise, {
|
|
855
|
-
destructor: () => task.destructor()
|
|
856
|
-
});
|
|
857
|
-
}
|
|
858
|
-
$.$mol_wait_timeout_async = $mol_wait_timeout_async;
|
|
859
|
-
function $mol_wait_timeout(timeout) {
|
|
860
|
-
return this.$mol_wire_sync(this).$mol_wait_timeout_async(timeout);
|
|
861
|
-
}
|
|
862
|
-
$.$mol_wait_timeout = $mol_wait_timeout;
|
|
863
|
-
})($ || ($ = {}));
|
|
864
|
-
//mol/wait/timeout/timeout.ts
|
|
865
|
-
;
|
|
866
|
-
"use strict";
|
|
867
|
-
var $;
|
|
868
764
|
(function ($_1) {
|
|
869
765
|
$mol_test({
|
|
870
766
|
async 'Latest method calls wins'($) {
|
|
@@ -908,36 +804,6 @@ var $;
|
|
|
908
804
|
;
|
|
909
805
|
"use strict";
|
|
910
806
|
var $;
|
|
911
|
-
(function ($) {
|
|
912
|
-
function $mol_wire_async(obj) {
|
|
913
|
-
let fiber;
|
|
914
|
-
const temp = $mol_wire_task.getter(obj);
|
|
915
|
-
return new Proxy(obj, {
|
|
916
|
-
get(obj, field) {
|
|
917
|
-
const val = obj[field];
|
|
918
|
-
if (typeof val !== 'function')
|
|
919
|
-
return val;
|
|
920
|
-
let fiber;
|
|
921
|
-
const temp = $mol_wire_task.getter(val);
|
|
922
|
-
return function $mol_wire_async(...args) {
|
|
923
|
-
fiber?.destructor();
|
|
924
|
-
fiber = temp(obj, args);
|
|
925
|
-
return fiber.async();
|
|
926
|
-
};
|
|
927
|
-
},
|
|
928
|
-
apply(obj, self, args) {
|
|
929
|
-
fiber?.destructor();
|
|
930
|
-
fiber = temp(self, args);
|
|
931
|
-
return fiber.async();
|
|
932
|
-
},
|
|
933
|
-
});
|
|
934
|
-
}
|
|
935
|
-
$.$mol_wire_async = $mol_wire_async;
|
|
936
|
-
})($ || ($ = {}));
|
|
937
|
-
//mol/wire/async/async.ts
|
|
938
|
-
;
|
|
939
|
-
"use strict";
|
|
940
|
-
var $;
|
|
941
807
|
(function ($_1) {
|
|
942
808
|
$mol_test({
|
|
943
809
|
'Cached channel'($) {
|
|
@@ -1508,77 +1374,6 @@ var $;
|
|
|
1508
1374
|
;
|
|
1509
1375
|
"use strict";
|
|
1510
1376
|
var $;
|
|
1511
|
-
(function ($) {
|
|
1512
|
-
function $mol_wire_probe(task, next) {
|
|
1513
|
-
const warm = $mol_wire_fiber.warm;
|
|
1514
|
-
try {
|
|
1515
|
-
$mol_wire_fiber.warm = false;
|
|
1516
|
-
return task();
|
|
1517
|
-
}
|
|
1518
|
-
finally {
|
|
1519
|
-
$mol_wire_fiber.warm = warm;
|
|
1520
|
-
}
|
|
1521
|
-
}
|
|
1522
|
-
$.$mol_wire_probe = $mol_wire_probe;
|
|
1523
|
-
})($ || ($ = {}));
|
|
1524
|
-
//mol/wire/probe/probe.ts
|
|
1525
|
-
;
|
|
1526
|
-
"use strict";
|
|
1527
|
-
var $;
|
|
1528
|
-
(function ($) {
|
|
1529
|
-
class $mol_wire_log extends $mol_object2 {
|
|
1530
|
-
static watch(task) {
|
|
1531
|
-
return task;
|
|
1532
|
-
}
|
|
1533
|
-
static track(fiber) {
|
|
1534
|
-
const prev = $mol_wire_probe(() => this.track(fiber));
|
|
1535
|
-
let next;
|
|
1536
|
-
try {
|
|
1537
|
-
next = fiber.sync();
|
|
1538
|
-
}
|
|
1539
|
-
finally {
|
|
1540
|
-
for (const pub of fiber.pub_list) {
|
|
1541
|
-
if (pub instanceof $mol_wire_fiber) {
|
|
1542
|
-
this.track(pub);
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1545
|
-
}
|
|
1546
|
-
if (prev !== undefined && !$mol_compare_deep(prev, next)) {
|
|
1547
|
-
this.$.$mol_log3_rise({
|
|
1548
|
-
message: 'Changed',
|
|
1549
|
-
place: fiber,
|
|
1550
|
-
});
|
|
1551
|
-
}
|
|
1552
|
-
return next;
|
|
1553
|
-
}
|
|
1554
|
-
static active() {
|
|
1555
|
-
try {
|
|
1556
|
-
this.watch()?.();
|
|
1557
|
-
}
|
|
1558
|
-
finally {
|
|
1559
|
-
for (const pub of $mol_wire_auto().pub_list) {
|
|
1560
|
-
if (pub instanceof $mol_wire_fiber) {
|
|
1561
|
-
this.track(pub);
|
|
1562
|
-
}
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
}
|
|
1566
|
-
}
|
|
1567
|
-
__decorate([
|
|
1568
|
-
$mol_mem
|
|
1569
|
-
], $mol_wire_log, "watch", null);
|
|
1570
|
-
__decorate([
|
|
1571
|
-
$mol_mem_key
|
|
1572
|
-
], $mol_wire_log, "track", null);
|
|
1573
|
-
__decorate([
|
|
1574
|
-
$mol_mem
|
|
1575
|
-
], $mol_wire_log, "active", null);
|
|
1576
|
-
$.$mol_wire_log = $mol_wire_log;
|
|
1577
|
-
})($ || ($ = {}));
|
|
1578
|
-
//mol/wire/log/log.ts
|
|
1579
|
-
;
|
|
1580
|
-
"use strict";
|
|
1581
|
-
var $;
|
|
1582
1377
|
(function ($) {
|
|
1583
1378
|
$mol_test({
|
|
1584
1379
|
'Primitives'() {
|
|
@@ -1734,5 +1529,277 @@ var $;
|
|
|
1734
1529
|
});
|
|
1735
1530
|
})($ || ($ = {}));
|
|
1736
1531
|
//mol/jsx/view/view.test.tsx
|
|
1532
|
+
;
|
|
1533
|
+
"use strict";
|
|
1534
|
+
var $;
|
|
1535
|
+
(function ($) {
|
|
1536
|
+
$mol_test({
|
|
1537
|
+
'const returns stored value'() {
|
|
1538
|
+
const foo = { bar: $mol_const(Math.random()) };
|
|
1539
|
+
$mol_assert_equal(foo.bar(), foo.bar());
|
|
1540
|
+
$mol_assert_equal(foo.bar(), foo.bar['()']);
|
|
1541
|
+
},
|
|
1542
|
+
});
|
|
1543
|
+
})($ || ($ = {}));
|
|
1544
|
+
//mol/const/const.test.ts
|
|
1545
|
+
;
|
|
1546
|
+
"use strict";
|
|
1547
|
+
var $;
|
|
1548
|
+
(function ($_1) {
|
|
1549
|
+
$mol_test({
|
|
1550
|
+
'Cached field'($) {
|
|
1551
|
+
class App extends $mol_object2 {
|
|
1552
|
+
static $ = $;
|
|
1553
|
+
static low = 1;
|
|
1554
|
+
static get high() {
|
|
1555
|
+
return this.low + 1;
|
|
1556
|
+
}
|
|
1557
|
+
static set high(next) {
|
|
1558
|
+
this.low = next - 1;
|
|
1559
|
+
}
|
|
1560
|
+
static test() {
|
|
1561
|
+
$mol_assert_equal(App.high, 2);
|
|
1562
|
+
App.high = 3;
|
|
1563
|
+
$mol_assert_equal(App.high, 3);
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
__decorate([
|
|
1567
|
+
$mol_wire_field
|
|
1568
|
+
], App, "low", void 0);
|
|
1569
|
+
__decorate([
|
|
1570
|
+
$mol_wire_field
|
|
1571
|
+
], App, "high", null);
|
|
1572
|
+
__decorate([
|
|
1573
|
+
$mol_wire_method
|
|
1574
|
+
], App, "test", null);
|
|
1575
|
+
App.test();
|
|
1576
|
+
},
|
|
1577
|
+
});
|
|
1578
|
+
})($ || ($ = {}));
|
|
1579
|
+
//mol/wire/field/field.test.ts
|
|
1580
|
+
;
|
|
1581
|
+
"use strict";
|
|
1582
|
+
var $;
|
|
1583
|
+
(function ($_1) {
|
|
1584
|
+
$mol_test({
|
|
1585
|
+
'Watch one value'($) {
|
|
1586
|
+
class App extends $mol_object2 {
|
|
1587
|
+
static $ = $;
|
|
1588
|
+
static set = new $mol_wire_set();
|
|
1589
|
+
static lucky() {
|
|
1590
|
+
return this.set.has(777);
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
__decorate([
|
|
1594
|
+
$mol_wire_mem(0)
|
|
1595
|
+
], App, "lucky", null);
|
|
1596
|
+
$mol_assert_equal(App.lucky(), false);
|
|
1597
|
+
App.set.add(666);
|
|
1598
|
+
$mol_assert_equal(App.lucky(), false);
|
|
1599
|
+
App.set.add(777);
|
|
1600
|
+
$mol_assert_equal(App.lucky(), true);
|
|
1601
|
+
App.set.delete(777);
|
|
1602
|
+
$mol_assert_equal(App.lucky(), false);
|
|
1603
|
+
},
|
|
1604
|
+
'Watch item channel'($) {
|
|
1605
|
+
class App extends $mol_object2 {
|
|
1606
|
+
static $ = $;
|
|
1607
|
+
static set = new $mol_wire_set();
|
|
1608
|
+
static lucky() {
|
|
1609
|
+
return this.set.item(777);
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
__decorate([
|
|
1613
|
+
$mol_wire_mem(0)
|
|
1614
|
+
], App, "lucky", null);
|
|
1615
|
+
$mol_assert_equal(App.lucky(), false);
|
|
1616
|
+
App.set.item(666, true);
|
|
1617
|
+
$mol_assert_equal(App.lucky(), false);
|
|
1618
|
+
App.set.item(777, true);
|
|
1619
|
+
$mol_assert_equal(App.lucky(), true);
|
|
1620
|
+
App.set.item(777, false);
|
|
1621
|
+
$mol_assert_equal(App.lucky(), false);
|
|
1622
|
+
},
|
|
1623
|
+
'Watch size'($) {
|
|
1624
|
+
class App extends $mol_object2 {
|
|
1625
|
+
static $ = $;
|
|
1626
|
+
static set = new $mol_wire_set();
|
|
1627
|
+
static size() {
|
|
1628
|
+
return this.set.size;
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
__decorate([
|
|
1632
|
+
$mol_wire_mem(0)
|
|
1633
|
+
], App, "size", null);
|
|
1634
|
+
$mol_assert_equal(App.size(), 0);
|
|
1635
|
+
App.set.add(666);
|
|
1636
|
+
$mol_assert_equal(App.size(), 1);
|
|
1637
|
+
App.set.add(777);
|
|
1638
|
+
$mol_assert_equal(App.size(), 2);
|
|
1639
|
+
App.set.delete(777);
|
|
1640
|
+
$mol_assert_equal(App.size(), 1);
|
|
1641
|
+
},
|
|
1642
|
+
'Watch for-of'($) {
|
|
1643
|
+
class App extends $mol_object2 {
|
|
1644
|
+
static $ = $;
|
|
1645
|
+
static set = new $mol_wire_set();
|
|
1646
|
+
static sum() {
|
|
1647
|
+
let res = 0;
|
|
1648
|
+
for (const val of this.set) {
|
|
1649
|
+
res += val;
|
|
1650
|
+
}
|
|
1651
|
+
return res;
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
__decorate([
|
|
1655
|
+
$mol_wire_mem(0)
|
|
1656
|
+
], App, "sum", null);
|
|
1657
|
+
$mol_assert_equal(App.sum(), 0);
|
|
1658
|
+
App.set.add(111);
|
|
1659
|
+
$mol_assert_equal(App.sum(), 111);
|
|
1660
|
+
App.set.add(222);
|
|
1661
|
+
$mol_assert_equal(App.sum(), 333);
|
|
1662
|
+
App.set.delete(111);
|
|
1663
|
+
$mol_assert_equal(App.sum(), 222);
|
|
1664
|
+
},
|
|
1665
|
+
'Watch forEach'($) {
|
|
1666
|
+
class App extends $mol_object2 {
|
|
1667
|
+
static $ = $;
|
|
1668
|
+
static set = new $mol_wire_set();
|
|
1669
|
+
static sum() {
|
|
1670
|
+
let res = 0;
|
|
1671
|
+
this.set.forEach(val => res += val);
|
|
1672
|
+
return res;
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
__decorate([
|
|
1676
|
+
$mol_wire_mem(0)
|
|
1677
|
+
], App, "sum", null);
|
|
1678
|
+
$mol_assert_equal(App.sum(), 0);
|
|
1679
|
+
App.set.add(111);
|
|
1680
|
+
$mol_assert_equal(App.sum(), 111);
|
|
1681
|
+
App.set.add(222);
|
|
1682
|
+
$mol_assert_equal(App.sum(), 333);
|
|
1683
|
+
App.set.delete(111);
|
|
1684
|
+
$mol_assert_equal(App.sum(), 222);
|
|
1685
|
+
},
|
|
1686
|
+
});
|
|
1687
|
+
})($ || ($ = {}));
|
|
1688
|
+
//mol/wire/set/set.test.ts
|
|
1689
|
+
;
|
|
1690
|
+
"use strict";
|
|
1691
|
+
var $;
|
|
1692
|
+
(function ($_1) {
|
|
1693
|
+
$mol_test({
|
|
1694
|
+
'Watch one value'($) {
|
|
1695
|
+
class App extends $mol_object2 {
|
|
1696
|
+
static $ = $;
|
|
1697
|
+
static dict = new $mol_wire_dict();
|
|
1698
|
+
static lucky() {
|
|
1699
|
+
return this.dict.get(777);
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
__decorate([
|
|
1703
|
+
$mol_wire_mem(0)
|
|
1704
|
+
], App, "lucky", null);
|
|
1705
|
+
$mol_assert_equal(App.lucky(), undefined);
|
|
1706
|
+
App.dict.set(666, 6666);
|
|
1707
|
+
$mol_assert_equal(App.lucky(), undefined);
|
|
1708
|
+
App.dict.set(777, 7777);
|
|
1709
|
+
$mol_assert_equal(App.lucky(), 7777);
|
|
1710
|
+
App.dict.delete(777);
|
|
1711
|
+
$mol_assert_equal(App.lucky(), undefined);
|
|
1712
|
+
},
|
|
1713
|
+
'Watch item channel'($) {
|
|
1714
|
+
class App extends $mol_object2 {
|
|
1715
|
+
static $ = $;
|
|
1716
|
+
static dict = new $mol_wire_dict();
|
|
1717
|
+
static lucky() {
|
|
1718
|
+
return this.dict.item(777);
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
__decorate([
|
|
1722
|
+
$mol_wire_mem(0)
|
|
1723
|
+
], App, "lucky", null);
|
|
1724
|
+
$mol_assert_equal(App.lucky(), null);
|
|
1725
|
+
App.dict.item(666, 6666);
|
|
1726
|
+
$mol_assert_equal(App.lucky(), null);
|
|
1727
|
+
App.dict.item(777, 7777);
|
|
1728
|
+
$mol_assert_equal(App.lucky(), 7777);
|
|
1729
|
+
App.dict.item(777, null);
|
|
1730
|
+
$mol_assert_equal(App.lucky(), null);
|
|
1731
|
+
},
|
|
1732
|
+
'Watch size'($) {
|
|
1733
|
+
class App extends $mol_object2 {
|
|
1734
|
+
static $ = $;
|
|
1735
|
+
static dict = new $mol_wire_dict();
|
|
1736
|
+
static size() {
|
|
1737
|
+
return this.dict.size;
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
__decorate([
|
|
1741
|
+
$mol_wire_mem(0)
|
|
1742
|
+
], App, "size", null);
|
|
1743
|
+
$mol_assert_equal(App.size(), 0);
|
|
1744
|
+
App.dict.set(666, 6666);
|
|
1745
|
+
$mol_assert_equal(App.size(), 1);
|
|
1746
|
+
App.dict.set(777, 7777);
|
|
1747
|
+
$mol_assert_equal(App.size(), 2);
|
|
1748
|
+
App.dict.delete(777);
|
|
1749
|
+
$mol_assert_equal(App.size(), 1);
|
|
1750
|
+
},
|
|
1751
|
+
'Watch for-of'($) {
|
|
1752
|
+
class App extends $mol_object2 {
|
|
1753
|
+
static $ = $;
|
|
1754
|
+
static dict = new $mol_wire_dict();
|
|
1755
|
+
static sum() {
|
|
1756
|
+
let keys = 0;
|
|
1757
|
+
let vals = 0;
|
|
1758
|
+
for (const [key, val] of this.dict) {
|
|
1759
|
+
keys += key;
|
|
1760
|
+
vals += val;
|
|
1761
|
+
}
|
|
1762
|
+
return [keys, vals];
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
__decorate([
|
|
1766
|
+
$mol_wire_mem(0)
|
|
1767
|
+
], App, "sum", null);
|
|
1768
|
+
$mol_assert_like(App.sum(), [0, 0]);
|
|
1769
|
+
App.dict.set(111, 1111);
|
|
1770
|
+
$mol_assert_like(App.sum(), [111, 1111]);
|
|
1771
|
+
App.dict.set(222, 2222);
|
|
1772
|
+
$mol_assert_like(App.sum(), [333, 3333]);
|
|
1773
|
+
App.dict.delete(111);
|
|
1774
|
+
$mol_assert_like(App.sum(), [222, 2222]);
|
|
1775
|
+
},
|
|
1776
|
+
'Watch forEach'($) {
|
|
1777
|
+
class App extends $mol_object2 {
|
|
1778
|
+
static $ = $;
|
|
1779
|
+
static dict = new $mol_wire_dict();
|
|
1780
|
+
static sum() {
|
|
1781
|
+
let keys = 0;
|
|
1782
|
+
let vals = 0;
|
|
1783
|
+
this.dict.forEach((val, key) => {
|
|
1784
|
+
keys += key;
|
|
1785
|
+
vals += val;
|
|
1786
|
+
});
|
|
1787
|
+
return [keys, vals];
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
__decorate([
|
|
1791
|
+
$mol_wire_mem(0)
|
|
1792
|
+
], App, "sum", null);
|
|
1793
|
+
$mol_assert_like(App.sum(), [0, 0]);
|
|
1794
|
+
App.dict.set(111, 1111);
|
|
1795
|
+
$mol_assert_like(App.sum(), [111, 1111]);
|
|
1796
|
+
App.dict.set(222, 2222);
|
|
1797
|
+
$mol_assert_like(App.sum(), [333, 3333]);
|
|
1798
|
+
App.dict.delete(111);
|
|
1799
|
+
$mol_assert_like(App.sum(), [222, 2222]);
|
|
1800
|
+
},
|
|
1801
|
+
});
|
|
1802
|
+
})($ || ($ = {}));
|
|
1803
|
+
//mol/wire/dict/dict.test.ts
|
|
1737
1804
|
|
|
1738
1805
|
//# sourceMappingURL=web.test.js.map
|