mol_jsx_lib 0.0.52 → 0.0.55
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 -5
- package/node.deps.json +1 -1
- package/node.esm.js +407 -0
- package/node.esm.js.map +1 -1
- package/node.js +407 -0
- package/node.js.map +1 -1
- package/node.test.js +679 -164
- package/node.test.js.map +1 -1
- package/package.json +17 -2
- package/web.d.ts +141 -5
- package/web.deps.json +1 -1
- package/web.esm.js +484 -0
- package/web.esm.js.map +1 -1
- package/web.js +484 -0
- package/web.js.map +1 -1
- package/web.test.js +272 -241
- package/web.test.js.map +1 -1
package/web.test.js
CHANGED
|
@@ -256,36 +256,9 @@ var $;
|
|
|
256
256
|
//mol/type/partial/deep/deep.test.ts
|
|
257
257
|
;
|
|
258
258
|
"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
259
|
//mol/type/keys/extract/extract.test.ts
|
|
284
260
|
;
|
|
285
261
|
"use strict";
|
|
286
|
-
//mol/type/keys/extract/extract.ts
|
|
287
|
-
;
|
|
288
|
-
"use strict";
|
|
289
262
|
var $;
|
|
290
263
|
(function ($_1) {
|
|
291
264
|
$mol_test_mocks.push($ => {
|
|
@@ -301,35 +274,6 @@ var $;
|
|
|
301
274
|
;
|
|
302
275
|
"use strict";
|
|
303
276
|
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
277
|
(function ($) {
|
|
334
278
|
$mol_test({
|
|
335
279
|
'Make empty div'() {
|
|
@@ -772,51 +716,6 @@ var $;
|
|
|
772
716
|
;
|
|
773
717
|
"use strict";
|
|
774
718
|
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
719
|
(function ($_1) {
|
|
821
720
|
$mol_test_mocks.push($ => {
|
|
822
721
|
$.$mol_after_timeout = $mol_after_mock_timeout;
|
|
@@ -826,45 +725,6 @@ var $;
|
|
|
826
725
|
;
|
|
827
726
|
"use strict";
|
|
828
727
|
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
728
|
(function ($_1) {
|
|
869
729
|
$mol_test({
|
|
870
730
|
async 'Latest method calls wins'($) {
|
|
@@ -908,36 +768,6 @@ var $;
|
|
|
908
768
|
;
|
|
909
769
|
"use strict";
|
|
910
770
|
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
771
|
(function ($_1) {
|
|
942
772
|
$mol_test({
|
|
943
773
|
'Cached channel'($) {
|
|
@@ -1508,77 +1338,6 @@ var $;
|
|
|
1508
1338
|
;
|
|
1509
1339
|
"use strict";
|
|
1510
1340
|
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
1341
|
(function ($) {
|
|
1583
1342
|
$mol_test({
|
|
1584
1343
|
'Primitives'() {
|
|
@@ -1734,5 +1493,277 @@ var $;
|
|
|
1734
1493
|
});
|
|
1735
1494
|
})($ || ($ = {}));
|
|
1736
1495
|
//mol/jsx/view/view.test.tsx
|
|
1496
|
+
;
|
|
1497
|
+
"use strict";
|
|
1498
|
+
var $;
|
|
1499
|
+
(function ($) {
|
|
1500
|
+
$mol_test({
|
|
1501
|
+
'const returns stored value'() {
|
|
1502
|
+
const foo = { bar: $mol_const(Math.random()) };
|
|
1503
|
+
$mol_assert_equal(foo.bar(), foo.bar());
|
|
1504
|
+
$mol_assert_equal(foo.bar(), foo.bar['()']);
|
|
1505
|
+
},
|
|
1506
|
+
});
|
|
1507
|
+
})($ || ($ = {}));
|
|
1508
|
+
//mol/const/const.test.ts
|
|
1509
|
+
;
|
|
1510
|
+
"use strict";
|
|
1511
|
+
var $;
|
|
1512
|
+
(function ($_1) {
|
|
1513
|
+
$mol_test({
|
|
1514
|
+
'Cached field'($) {
|
|
1515
|
+
class App extends $mol_object2 {
|
|
1516
|
+
static $ = $;
|
|
1517
|
+
static low = 1;
|
|
1518
|
+
static get high() {
|
|
1519
|
+
return this.low + 1;
|
|
1520
|
+
}
|
|
1521
|
+
static set high(next) {
|
|
1522
|
+
this.low = next - 1;
|
|
1523
|
+
}
|
|
1524
|
+
static test() {
|
|
1525
|
+
$mol_assert_equal(App.high, 2);
|
|
1526
|
+
App.high = 3;
|
|
1527
|
+
$mol_assert_equal(App.high, 3);
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
__decorate([
|
|
1531
|
+
$mol_wire_field
|
|
1532
|
+
], App, "low", void 0);
|
|
1533
|
+
__decorate([
|
|
1534
|
+
$mol_wire_field
|
|
1535
|
+
], App, "high", null);
|
|
1536
|
+
__decorate([
|
|
1537
|
+
$mol_wire_method
|
|
1538
|
+
], App, "test", null);
|
|
1539
|
+
App.test();
|
|
1540
|
+
},
|
|
1541
|
+
});
|
|
1542
|
+
})($ || ($ = {}));
|
|
1543
|
+
//mol/wire/field/field.test.ts
|
|
1544
|
+
;
|
|
1545
|
+
"use strict";
|
|
1546
|
+
var $;
|
|
1547
|
+
(function ($_1) {
|
|
1548
|
+
$mol_test({
|
|
1549
|
+
'Watch one value'($) {
|
|
1550
|
+
class App extends $mol_object2 {
|
|
1551
|
+
static $ = $;
|
|
1552
|
+
static set = new $mol_wire_set();
|
|
1553
|
+
static lucky() {
|
|
1554
|
+
return this.set.has(777);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
__decorate([
|
|
1558
|
+
$mol_wire_mem(0)
|
|
1559
|
+
], App, "lucky", null);
|
|
1560
|
+
$mol_assert_equal(App.lucky(), false);
|
|
1561
|
+
App.set.add(666);
|
|
1562
|
+
$mol_assert_equal(App.lucky(), false);
|
|
1563
|
+
App.set.add(777);
|
|
1564
|
+
$mol_assert_equal(App.lucky(), true);
|
|
1565
|
+
App.set.delete(777);
|
|
1566
|
+
$mol_assert_equal(App.lucky(), false);
|
|
1567
|
+
},
|
|
1568
|
+
'Watch item channel'($) {
|
|
1569
|
+
class App extends $mol_object2 {
|
|
1570
|
+
static $ = $;
|
|
1571
|
+
static set = new $mol_wire_set();
|
|
1572
|
+
static lucky() {
|
|
1573
|
+
return this.set.item(777);
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
__decorate([
|
|
1577
|
+
$mol_wire_mem(0)
|
|
1578
|
+
], App, "lucky", null);
|
|
1579
|
+
$mol_assert_equal(App.lucky(), false);
|
|
1580
|
+
App.set.item(666, true);
|
|
1581
|
+
$mol_assert_equal(App.lucky(), false);
|
|
1582
|
+
App.set.item(777, true);
|
|
1583
|
+
$mol_assert_equal(App.lucky(), true);
|
|
1584
|
+
App.set.item(777, false);
|
|
1585
|
+
$mol_assert_equal(App.lucky(), false);
|
|
1586
|
+
},
|
|
1587
|
+
'Watch size'($) {
|
|
1588
|
+
class App extends $mol_object2 {
|
|
1589
|
+
static $ = $;
|
|
1590
|
+
static set = new $mol_wire_set();
|
|
1591
|
+
static size() {
|
|
1592
|
+
return this.set.size;
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
__decorate([
|
|
1596
|
+
$mol_wire_mem(0)
|
|
1597
|
+
], App, "size", null);
|
|
1598
|
+
$mol_assert_equal(App.size(), 0);
|
|
1599
|
+
App.set.add(666);
|
|
1600
|
+
$mol_assert_equal(App.size(), 1);
|
|
1601
|
+
App.set.add(777);
|
|
1602
|
+
$mol_assert_equal(App.size(), 2);
|
|
1603
|
+
App.set.delete(777);
|
|
1604
|
+
$mol_assert_equal(App.size(), 1);
|
|
1605
|
+
},
|
|
1606
|
+
'Watch for-of'($) {
|
|
1607
|
+
class App extends $mol_object2 {
|
|
1608
|
+
static $ = $;
|
|
1609
|
+
static set = new $mol_wire_set();
|
|
1610
|
+
static sum() {
|
|
1611
|
+
let res = 0;
|
|
1612
|
+
for (const val of this.set) {
|
|
1613
|
+
res += val;
|
|
1614
|
+
}
|
|
1615
|
+
return res;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
__decorate([
|
|
1619
|
+
$mol_wire_mem(0)
|
|
1620
|
+
], App, "sum", null);
|
|
1621
|
+
$mol_assert_equal(App.sum(), 0);
|
|
1622
|
+
App.set.add(111);
|
|
1623
|
+
$mol_assert_equal(App.sum(), 111);
|
|
1624
|
+
App.set.add(222);
|
|
1625
|
+
$mol_assert_equal(App.sum(), 333);
|
|
1626
|
+
App.set.delete(111);
|
|
1627
|
+
$mol_assert_equal(App.sum(), 222);
|
|
1628
|
+
},
|
|
1629
|
+
'Watch forEach'($) {
|
|
1630
|
+
class App extends $mol_object2 {
|
|
1631
|
+
static $ = $;
|
|
1632
|
+
static set = new $mol_wire_set();
|
|
1633
|
+
static sum() {
|
|
1634
|
+
let res = 0;
|
|
1635
|
+
this.set.forEach(val => res += val);
|
|
1636
|
+
return res;
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
__decorate([
|
|
1640
|
+
$mol_wire_mem(0)
|
|
1641
|
+
], App, "sum", null);
|
|
1642
|
+
$mol_assert_equal(App.sum(), 0);
|
|
1643
|
+
App.set.add(111);
|
|
1644
|
+
$mol_assert_equal(App.sum(), 111);
|
|
1645
|
+
App.set.add(222);
|
|
1646
|
+
$mol_assert_equal(App.sum(), 333);
|
|
1647
|
+
App.set.delete(111);
|
|
1648
|
+
$mol_assert_equal(App.sum(), 222);
|
|
1649
|
+
},
|
|
1650
|
+
});
|
|
1651
|
+
})($ || ($ = {}));
|
|
1652
|
+
//mol/wire/set/set.test.ts
|
|
1653
|
+
;
|
|
1654
|
+
"use strict";
|
|
1655
|
+
var $;
|
|
1656
|
+
(function ($_1) {
|
|
1657
|
+
$mol_test({
|
|
1658
|
+
'Watch one value'($) {
|
|
1659
|
+
class App extends $mol_object2 {
|
|
1660
|
+
static $ = $;
|
|
1661
|
+
static dict = new $mol_wire_dict();
|
|
1662
|
+
static lucky() {
|
|
1663
|
+
return this.dict.get(777);
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
__decorate([
|
|
1667
|
+
$mol_wire_mem(0)
|
|
1668
|
+
], App, "lucky", null);
|
|
1669
|
+
$mol_assert_equal(App.lucky(), undefined);
|
|
1670
|
+
App.dict.set(666, 6666);
|
|
1671
|
+
$mol_assert_equal(App.lucky(), undefined);
|
|
1672
|
+
App.dict.set(777, 7777);
|
|
1673
|
+
$mol_assert_equal(App.lucky(), 7777);
|
|
1674
|
+
App.dict.delete(777);
|
|
1675
|
+
$mol_assert_equal(App.lucky(), undefined);
|
|
1676
|
+
},
|
|
1677
|
+
'Watch item channel'($) {
|
|
1678
|
+
class App extends $mol_object2 {
|
|
1679
|
+
static $ = $;
|
|
1680
|
+
static dict = new $mol_wire_dict();
|
|
1681
|
+
static lucky() {
|
|
1682
|
+
return this.dict.item(777);
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
__decorate([
|
|
1686
|
+
$mol_wire_mem(0)
|
|
1687
|
+
], App, "lucky", null);
|
|
1688
|
+
$mol_assert_equal(App.lucky(), null);
|
|
1689
|
+
App.dict.item(666, 6666);
|
|
1690
|
+
$mol_assert_equal(App.lucky(), null);
|
|
1691
|
+
App.dict.item(777, 7777);
|
|
1692
|
+
$mol_assert_equal(App.lucky(), 7777);
|
|
1693
|
+
App.dict.item(777, null);
|
|
1694
|
+
$mol_assert_equal(App.lucky(), null);
|
|
1695
|
+
},
|
|
1696
|
+
'Watch size'($) {
|
|
1697
|
+
class App extends $mol_object2 {
|
|
1698
|
+
static $ = $;
|
|
1699
|
+
static dict = new $mol_wire_dict();
|
|
1700
|
+
static size() {
|
|
1701
|
+
return this.dict.size;
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
__decorate([
|
|
1705
|
+
$mol_wire_mem(0)
|
|
1706
|
+
], App, "size", null);
|
|
1707
|
+
$mol_assert_equal(App.size(), 0);
|
|
1708
|
+
App.dict.set(666, 6666);
|
|
1709
|
+
$mol_assert_equal(App.size(), 1);
|
|
1710
|
+
App.dict.set(777, 7777);
|
|
1711
|
+
$mol_assert_equal(App.size(), 2);
|
|
1712
|
+
App.dict.delete(777);
|
|
1713
|
+
$mol_assert_equal(App.size(), 1);
|
|
1714
|
+
},
|
|
1715
|
+
'Watch for-of'($) {
|
|
1716
|
+
class App extends $mol_object2 {
|
|
1717
|
+
static $ = $;
|
|
1718
|
+
static dict = new $mol_wire_dict();
|
|
1719
|
+
static sum() {
|
|
1720
|
+
let keys = 0;
|
|
1721
|
+
let vals = 0;
|
|
1722
|
+
for (const [key, val] of this.dict) {
|
|
1723
|
+
keys += key;
|
|
1724
|
+
vals += val;
|
|
1725
|
+
}
|
|
1726
|
+
return [keys, vals];
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
__decorate([
|
|
1730
|
+
$mol_wire_mem(0)
|
|
1731
|
+
], App, "sum", null);
|
|
1732
|
+
$mol_assert_like(App.sum(), [0, 0]);
|
|
1733
|
+
App.dict.set(111, 1111);
|
|
1734
|
+
$mol_assert_like(App.sum(), [111, 1111]);
|
|
1735
|
+
App.dict.set(222, 2222);
|
|
1736
|
+
$mol_assert_like(App.sum(), [333, 3333]);
|
|
1737
|
+
App.dict.delete(111);
|
|
1738
|
+
$mol_assert_like(App.sum(), [222, 2222]);
|
|
1739
|
+
},
|
|
1740
|
+
'Watch forEach'($) {
|
|
1741
|
+
class App extends $mol_object2 {
|
|
1742
|
+
static $ = $;
|
|
1743
|
+
static dict = new $mol_wire_dict();
|
|
1744
|
+
static sum() {
|
|
1745
|
+
let keys = 0;
|
|
1746
|
+
let vals = 0;
|
|
1747
|
+
this.dict.forEach((val, key) => {
|
|
1748
|
+
keys += key;
|
|
1749
|
+
vals += val;
|
|
1750
|
+
});
|
|
1751
|
+
return [keys, vals];
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
__decorate([
|
|
1755
|
+
$mol_wire_mem(0)
|
|
1756
|
+
], App, "sum", null);
|
|
1757
|
+
$mol_assert_like(App.sum(), [0, 0]);
|
|
1758
|
+
App.dict.set(111, 1111);
|
|
1759
|
+
$mol_assert_like(App.sum(), [111, 1111]);
|
|
1760
|
+
App.dict.set(222, 2222);
|
|
1761
|
+
$mol_assert_like(App.sum(), [333, 3333]);
|
|
1762
|
+
App.dict.delete(111);
|
|
1763
|
+
$mol_assert_like(App.sum(), [222, 2222]);
|
|
1764
|
+
},
|
|
1765
|
+
});
|
|
1766
|
+
})($ || ($ = {}));
|
|
1767
|
+
//mol/wire/dict/dict.test.ts
|
|
1737
1768
|
|
|
1738
1769
|
//# sourceMappingURL=web.test.js.map
|