mol_dump_lib 0.0.1026 → 0.0.1028

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/web.test.js CHANGED
@@ -8,6 +8,12 @@ function require( path ){ return $node[ path ] };
8
8
  ;
9
9
  "use strict";
10
10
 
11
+ ;
12
+ "use strict";
13
+
14
+ ;
15
+ "use strict";
16
+
11
17
  ;
12
18
  "use strict";
13
19
  var $;
@@ -108,18 +114,34 @@ var $;
108
114
  "use strict";
109
115
  var $;
110
116
  (function ($) {
117
+ /**
118
+ * Argument must be Truthy
119
+ * @deprecated use $mol_assert_equal instead
120
+ */
111
121
  function $mol_assert_ok(value) {
112
122
  if (value)
113
123
  return;
114
124
  $mol_fail(new Error(`${value} ≠ true`));
115
125
  }
116
126
  $.$mol_assert_ok = $mol_assert_ok;
127
+ /**
128
+ * Argument must be Falsy
129
+ * @deprecated use $mol_assert_equal instead
130
+ */
117
131
  function $mol_assert_not(value) {
118
132
  if (!value)
119
133
  return;
120
134
  $mol_fail(new Error(`${value} ≠ false`));
121
135
  }
122
136
  $.$mol_assert_not = $mol_assert_not;
137
+ /**
138
+ * Handler must throw an error.
139
+ * @example
140
+ * $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } ) // Passes because throws error
141
+ * $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } , 'Parse error' ) // Passes because throws right message
142
+ * $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } , Error ) // Passes because throws right class
143
+ * @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
144
+ */
123
145
  function $mol_assert_fail(handler, ErrorRight) {
124
146
  const fail = $.$mol_fail;
125
147
  try {
@@ -142,10 +164,18 @@ var $;
142
164
  $mol_fail(new Error('Not failed', { cause: { expect: ErrorRight } }));
143
165
  }
144
166
  $.$mol_assert_fail = $mol_assert_fail;
167
+ /** @deprecated Use $mol_assert_equal */
145
168
  function $mol_assert_like(...args) {
146
169
  $mol_assert_equal(...args);
147
170
  }
148
171
  $.$mol_assert_like = $mol_assert_like;
172
+ /**
173
+ * All arguments must not be structural equal to each other.
174
+ * @example
175
+ * $mol_assert_unique( 1 , 2 , 3 ) // Passes
176
+ * $mol_assert_unique( 1 , 1 , 2 ) // Fails because 1 === 1
177
+ * @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
178
+ */
149
179
  function $mol_assert_unique(...args) {
150
180
  for (let i = 0; i < args.length; ++i) {
151
181
  for (let j = 0; j < args.length; ++j) {
@@ -158,6 +188,13 @@ var $;
158
188
  }
159
189
  }
160
190
  $.$mol_assert_unique = $mol_assert_unique;
191
+ /**
192
+ * All arguments must be structural equal each other.
193
+ * @example
194
+ * $mol_assert_like( [1] , [1] , [1] ) // Passes
195
+ * $mol_assert_like( [1] , [1] , [2] ) // Fails because 1 !== 2
196
+ * @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
197
+ */
161
198
  function $mol_assert_equal(...args) {
162
199
  for (let i = 1; i < args.length; ++i) {
163
200
  if ($mol_compare_deep(args[0], args[i]))
@@ -219,6 +256,8 @@ var $;
219
256
 
220
257
  ;
221
258
  "use strict";
259
+ /** @jsx $mol_jsx */
260
+ /** @jsxFrag $mol_jsx_frag */
222
261
  var $;
223
262
  (function ($) {
224
263
  $mol_test({
@@ -389,9 +428,6 @@ var $;
389
428
  ;
390
429
  "use strict";
391
430
 
392
- ;
393
- "use strict";
394
-
395
431
  ;
396
432
  "use strict";
397
433
  var $;
@@ -508,6 +544,7 @@ var $;
508
544
  "use strict";
509
545
  var $;
510
546
  (function ($) {
547
+ /// @todo right orderinng
511
548
  $.$mol_after_mock_queue = [];
512
549
  function $mol_after_mock_warp() {
513
550
  const queue = $.$mol_after_mock_queue.splice(0);
@@ -640,6 +677,7 @@ var $;
640
677
  "use strict";
641
678
  var $;
642
679
  (function ($) {
680
+ /** Lazy computed lists with native Array interface. $mol_range2_array is mutable but all derived ranges are immutable. */
643
681
  function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
644
682
  const source = typeof item === 'function' ? new $mol_range2_array() : item;
645
683
  if (typeof item !== 'function') {
@@ -688,6 +726,7 @@ var $;
688
726
  }
689
727
  $.$mol_range2 = $mol_range2;
690
728
  class $mol_range2_array extends Array {
729
+ // Lazy
691
730
  concat(...tail) {
692
731
  if (tail.length === 0)
693
732
  return this;
@@ -699,6 +738,7 @@ var $;
699
738
  }
700
739
  return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
701
740
  }
741
+ // Lazy
702
742
  filter(check, context) {
703
743
  const filtered = [];
704
744
  let cursor = -1;
@@ -711,13 +751,16 @@ var $;
711
751
  return filtered[index];
712
752
  }, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
713
753
  }
754
+ // Diligent
714
755
  forEach(proceed, context) {
715
756
  for (let [key, value] of this.entries())
716
757
  proceed.call(context, value, key, this);
717
758
  }
759
+ // Lazy
718
760
  map(proceed, context) {
719
761
  return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
720
762
  }
763
+ // Diligent
721
764
  reduce(merge, result) {
722
765
  let index = 0;
723
766
  if (arguments.length === 1) {
@@ -728,12 +771,15 @@ var $;
728
771
  }
729
772
  return result;
730
773
  }
774
+ // Lazy
731
775
  toReversed() {
732
776
  return $mol_range2(index => this[this.length - 1 - index], () => this.length);
733
777
  }
778
+ // Lazy
734
779
  slice(from = 0, to = this.length) {
735
780
  return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
736
781
  }
782
+ // Lazy
737
783
  some(check, context) {
738
784
  for (let index = 0; index < this.length; ++index) {
739
785
  if (check.call(context, this[index], index, this))
@@ -926,6 +972,7 @@ var $;
926
972
 
927
973
  ;
928
974
  "use strict";
975
+ /** @jsx $mol_jsx */
929
976
  var $;
930
977
  (function ($) {
931
978
  $mol_test({
@@ -987,6 +1034,7 @@ var $;
987
1034
  const obj3_copy = { test: 3, obj2: obj2_copy };
988
1035
  obj1.obj3 = obj3;
989
1036
  obj1_copy.obj3 = obj3_copy;
1037
+ // warmup cache
990
1038
  $mol_assert_not($mol_compare_deep(obj1, {}));
991
1039
  $mol_assert_not($mol_compare_deep(obj2, {}));
992
1040
  $mol_assert_not($mol_compare_deep(obj3, {}));
@@ -1265,6 +1313,7 @@ var $;
1265
1313
  var $;
1266
1314
  (function ($_1) {
1267
1315
  $mol_test({
1316
+ // https://github.com/nin-jin/slides/tree/master/reactivity#component-states
1268
1317
  'Cached channel'($) {
1269
1318
  class App extends $mol_object2 {
1270
1319
  static $ = $;
@@ -1322,6 +1371,7 @@ var $;
1322
1371
  $mol_assert_equal(App.value(5), 21);
1323
1372
  $mol_assert_equal(App.value(), 21);
1324
1373
  },
1374
+ // https://github.com/nin-jin/slides/tree/master/reactivity#wish-consistency
1325
1375
  'Auto recalculation of cached values'($) {
1326
1376
  class App extends $mol_object2 {
1327
1377
  static $ = $;
@@ -1349,6 +1399,7 @@ var $;
1349
1399
  App.xxx(5);
1350
1400
  $mol_assert_equal(App.zzz(), 7);
1351
1401
  },
1402
+ // https://github.com/nin-jin/slides/tree/master/reactivity#wish-reasonability
1352
1403
  'Skip recalculation when actually no dependency changes'($) {
1353
1404
  const log = [];
1354
1405
  class App extends $mol_object2 {
@@ -1382,6 +1433,7 @@ var $;
1382
1433
  App.zzz();
1383
1434
  $mol_assert_like(log, ['zzz', 'yyy', 'xxx', 'xxx', 'yyy']);
1384
1435
  },
1436
+ // https://github.com/nin-jin/slides/tree/master/reactivity#flow-auto
1385
1437
  'Flow: Auto'($) {
1386
1438
  class App extends $mol_object2 {
1387
1439
  static get $() { return $; }
@@ -1419,6 +1471,7 @@ var $;
1419
1471
  $mol_assert_equal(App.result(), 23);
1420
1472
  $mol_assert_equal(App.counter, 4);
1421
1473
  },
1474
+ // https://github.com/nin-jin/slides/tree/master/reactivity#dupes-equality
1422
1475
  'Dupes: Equality'($) {
1423
1476
  let counter = 0;
1424
1477
  class App extends $mol_object2 {
@@ -1442,6 +1495,7 @@ var $;
1442
1495
  App.foo({ numbs: [2] });
1443
1496
  $mol_assert_like(App.bar(), { numbs: [2], count: 2 });
1444
1497
  },
1498
+ // https://github.com/nin-jin/slides/tree/master/reactivity#cycle-fail
1445
1499
  'Cycle: Fail'($) {
1446
1500
  class App extends $mol_object2 {
1447
1501
  static $ = $;
@@ -1466,6 +1520,29 @@ var $;
1466
1520
  ], App, "test", null);
1467
1521
  App.test();
1468
1522
  },
1523
+ // https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
1524
+ // 'Update deps on push'( $ ) {
1525
+ // class App extends $mol_object2 {
1526
+ // static $ = $
1527
+ // @ $mol_wire_solo
1528
+ // static left( next = false ) {
1529
+ // return next
1530
+ // }
1531
+ // @ $mol_wire_solo
1532
+ // static right( next = false ) {
1533
+ // return next
1534
+ // }
1535
+ // @ $mol_wire_solo
1536
+ // static res( next?: boolean ) {
1537
+ // return this.left( next ) && this.right()
1538
+ // }
1539
+ // }
1540
+ // $mol_assert_equal( App.res(), false )
1541
+ // $mol_assert_equal( App.res( true ), false )
1542
+ // $mol_assert_equal( App.right( true ), true )
1543
+ // $mol_assert_equal( App.res(), true )
1544
+ // } ,
1545
+ // https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
1469
1546
  'Different order of pull and push'($) {
1470
1547
  class App extends $mol_object2 {
1471
1548
  static $ = $;
@@ -1477,7 +1554,7 @@ var $;
1477
1554
  }
1478
1555
  static slow(next) {
1479
1556
  if (next !== undefined)
1480
- this.slow();
1557
+ this.slow(); // enforce pull before push
1481
1558
  return this.store(next);
1482
1559
  }
1483
1560
  }
@@ -1496,6 +1573,7 @@ var $;
1496
1573
  App.store(777);
1497
1574
  $mol_assert_equal(App.fast(), App.slow(), 777);
1498
1575
  },
1576
+ // https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
1499
1577
  'Actions inside invariant'($) {
1500
1578
  class App extends $mol_object2 {
1501
1579
  static $ = $;
@@ -1535,6 +1613,7 @@ var $;
1535
1613
  static toggle() {
1536
1614
  const prev = this.checked();
1537
1615
  $mol_assert_unique(this.checked(!prev), prev);
1616
+ // $mol_assert_equal( this.checked() , prev )
1538
1617
  }
1539
1618
  static res() {
1540
1619
  return this.checked();
@@ -1559,6 +1638,39 @@ var $;
1559
1638
  ], App, "test", null);
1560
1639
  await $mol_wire_async(App).test();
1561
1640
  },
1641
+ // // https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
1642
+ // 'Stable order of multiple root'( $ ) {
1643
+ // class App extends $mol_object2 {
1644
+ // static $ = $
1645
+ // static counter = 0
1646
+ // @ $mol_wire_solo
1647
+ // static left_trigger( next = 0 ) {
1648
+ // return next
1649
+ // }
1650
+ // @ $mol_wire_solo
1651
+ // static left_root() {
1652
+ // this.left_trigger()
1653
+ // return ++ this.counter
1654
+ // }
1655
+ // @ $mol_wire_solo
1656
+ // static right_trigger( next = 0 ) {
1657
+ // return next
1658
+ // }
1659
+ // @ $mol_wire_solo
1660
+ // static right_root() {
1661
+ // this.right_trigger()
1662
+ // return ++ this.counter
1663
+ // }
1664
+ // }
1665
+ // $mol_assert_equal( App.left_root(), 1 )
1666
+ // $mol_assert_equal( App.right_root(), 2 )
1667
+ // App.right_trigger( 1 )
1668
+ // App.left_trigger( 1 )
1669
+ // $mol_wire_fiber.sync()
1670
+ // $mol_assert_equal( App.right_root(), 4 )
1671
+ // $mol_assert_equal( App.left_root(), 3 )
1672
+ // } ,
1673
+ // https://github.com/nin-jin/slides/tree/master/reactivity#error-store
1562
1674
  'Restore after error'($) {
1563
1675
  class App extends $mol_object2 {
1564
1676
  static get $() { return $; }
@@ -1656,6 +1768,7 @@ var $;
1656
1768
  App.showing(true);
1657
1769
  $mol_assert_unique(App.render(), details);
1658
1770
  },
1771
+ // https://github.com/nin-jin/slides/tree/master/reactivity#wish-stability
1659
1772
  async 'Hold pubs while wait async task'($) {
1660
1773
  class App extends $mol_object2 {
1661
1774
  static $ = $;
@@ -1871,6 +1984,7 @@ var $;
1871
1984
 
1872
1985
  ;
1873
1986
  "use strict";
1987
+ /** @jsx $mol_jsx */
1874
1988
  var $;
1875
1989
  (function ($) {
1876
1990
  $mol_test({
@@ -1956,6 +2070,12 @@ var $;
1956
2070
  'return result without errors'() {
1957
2071
  $mol_assert_equal($mol_try(() => false), false);
1958
2072
  },
2073
+ //'return error if thrown'() {
2074
+ //
2075
+ // const error = new Error( '$mol_try test error' )
2076
+ // $mol_assert_equal( $mol_try( ()=> { throw error } ) , error )
2077
+ //
2078
+ //} ,
1959
2079
  });
1960
2080
  })($ || ($ = {}));
1961
2081
 
@@ -1970,6 +2090,7 @@ var $;
1970
2090
  "use strict";
1971
2091
  var $;
1972
2092
  (function ($) {
2093
+ /** Watch and logs reactive states. Logger automatically added to test bundle which is adding to `test.html`. */
1973
2094
  class $mol_wire_log extends $mol_object2 {
1974
2095
  static watch(task) {
1975
2096
  return task;
@@ -2211,6 +2332,9 @@ var $;
2211
2332
  });
2212
2333
  })($ || ($ = {}));
2213
2334
 
2335
+ ;
2336
+ "use strict";
2337
+
2214
2338
  ;
2215
2339
  "use strict";
2216
2340
  var $;