mol_db 0.0.1730 → 0.0.1732

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
@@ -29,7 +29,7 @@ var $;
29
29
  var $;
30
30
  (function ($) {
31
31
  function $mol_fail_hidden(error) {
32
- throw error;
32
+ throw error; /// Use 'Never Pause Here' breakpoint in DevTools or simply blackbox this script
33
33
  }
34
34
  $.$mol_fail_hidden = $mol_fail_hidden;
35
35
  })($ || ($ = {}));
@@ -224,6 +224,12 @@ var $;
224
224
  createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
225
225
  };
226
226
  $.$mol_jsx_frag = '';
227
+ /**
228
+ * JSX adapter that makes DOM tree.
229
+ * Generates global unique ids for every DOM-element by components tree with ids.
230
+ * Ensures all local ids are unique.
231
+ * Can reuse an existing nodes by GUIDs when used inside [`mol_jsx_attach`](https://github.com/hyoo-ru/mam_mol/tree/master/jsx/attach).
232
+ */
227
233
  function $mol_jsx(Elem, props, ...childNodes) {
228
234
  const id = props && props.id || '';
229
235
  const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
@@ -334,6 +340,8 @@ var $;
334
340
 
335
341
  ;
336
342
  "use strict";
343
+ /** @jsx $mol_jsx */
344
+ /** @jsxFrag $mol_jsx_frag */
337
345
  var $;
338
346
  (function ($) {
339
347
  $mol_test({
@@ -439,6 +447,7 @@ var $;
439
447
  "use strict";
440
448
  var $;
441
449
  (function ($) {
450
+ /** Generates unique identifier. */
442
451
  function $mol_guid(length = 8, exists = () => false) {
443
452
  for (;;) {
444
453
  let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
@@ -454,6 +463,7 @@ var $;
454
463
  "use strict";
455
464
  var $;
456
465
  (function ($) {
466
+ /** Lazy computed lists with native Array interface. $mol_range2_array is mutable but all derived ranges are immutable. */
457
467
  function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
458
468
  const source = typeof item === 'function' ? new $mol_range2_array() : item;
459
469
  if (typeof item !== 'function') {
@@ -502,6 +512,7 @@ var $;
502
512
  }
503
513
  $.$mol_range2 = $mol_range2;
504
514
  class $mol_range2_array extends Array {
515
+ // Lazy
505
516
  concat(...tail) {
506
517
  if (tail.length === 0)
507
518
  return this;
@@ -513,6 +524,7 @@ var $;
513
524
  }
514
525
  return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
515
526
  }
527
+ // Lazy
516
528
  filter(check, context) {
517
529
  const filtered = [];
518
530
  let cursor = -1;
@@ -525,13 +537,16 @@ var $;
525
537
  return filtered[index];
526
538
  }, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
527
539
  }
540
+ // Diligent
528
541
  forEach(proceed, context) {
529
542
  for (let [key, value] of this.entries())
530
543
  proceed.call(context, value, key, this);
531
544
  }
545
+ // Lazy
532
546
  map(proceed, context) {
533
547
  return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
534
548
  }
549
+ // Diligent
535
550
  reduce(merge, result) {
536
551
  let index = 0;
537
552
  if (arguments.length === 1) {
@@ -542,12 +557,15 @@ var $;
542
557
  }
543
558
  return result;
544
559
  }
560
+ // Lazy
545
561
  toReversed() {
546
562
  return $mol_range2(index => this[this.length - 1 - index], () => this.length);
547
563
  }
564
+ // Lazy
548
565
  slice(from = 0, to = this.length) {
549
566
  return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
550
567
  }
568
+ // Lazy
551
569
  some(check, context) {
552
570
  for (let index = 0; index < this.length; ++index) {
553
571
  if (check.call(context, this[index], index, this))
@@ -743,6 +761,10 @@ var $;
743
761
  var $;
744
762
  (function ($) {
745
763
  $.$mol_compare_deep_cache = new WeakMap();
764
+ /**
765
+ * Deeply compares two values. Returns true if equal.
766
+ * Define `Symbol.toPrimitive` to customize.
767
+ */
746
768
  function $mol_compare_deep(left, right) {
747
769
  if (Object.is(left, right))
748
770
  return true;
@@ -880,6 +902,7 @@ var $;
880
902
 
881
903
  ;
882
904
  "use strict";
905
+ /** @jsx $mol_jsx */
883
906
  var $;
884
907
  (function ($) {
885
908
  $mol_test({
@@ -941,6 +964,7 @@ var $;
941
964
  const obj3_copy = { test: 3, obj2: obj2_copy };
942
965
  obj1.obj3 = obj3;
943
966
  obj1_copy.obj3 = obj3_copy;
967
+ // warmup cache
944
968
  $mol_assert_not($mol_compare_deep(obj1, {}));
945
969
  $mol_assert_not($mol_compare_deep(obj2, {}));
946
970
  $mol_assert_not($mol_compare_deep(obj3, {}));
@@ -1010,6 +1034,7 @@ var $;
1010
1034
  "use strict";
1011
1035
  var $;
1012
1036
  (function ($) {
1037
+ // https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview#
1013
1038
  $['devtoolsFormatters'] ||= [];
1014
1039
  function $mol_dev_format_register(config) {
1015
1040
  $['devtoolsFormatters'].push(config);
@@ -1061,6 +1086,7 @@ var $;
1061
1086
  return false;
1062
1087
  if (!val)
1063
1088
  return false;
1089
+ // if( Error.isError( val ) ) true
1064
1090
  if (val[$.$mol_dev_format_body])
1065
1091
  return true;
1066
1092
  return false;
@@ -1078,12 +1104,16 @@ var $;
1078
1104
  return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
1079
1105
  }
1080
1106
  }
1107
+ // if( Error.isError( val ) ) {
1108
+ // return $mol_dev_format_native( val )
1109
+ // }
1081
1110
  return null;
1082
1111
  },
1083
1112
  });
1084
1113
  function $mol_dev_format_native(obj) {
1085
1114
  if (typeof obj === 'undefined')
1086
1115
  return $.$mol_dev_format_shade('undefined');
1116
+ // if( ![ 'object', 'function', 'symbol' ].includes( typeof obj ) ) return obj
1087
1117
  return [
1088
1118
  'object',
1089
1119
  {
@@ -1141,6 +1171,9 @@ var $;
1141
1171
  'margin-left': '13px'
1142
1172
  });
1143
1173
  class Stack extends Array {
1174
+ // [ Symbol.toPrimitive ]() {
1175
+ // return this.toString()
1176
+ // }
1144
1177
  toString() {
1145
1178
  return this.join('\n');
1146
1179
  }
@@ -1163,6 +1196,7 @@ var $;
1163
1196
  this.method = call.getMethodName() ?? '';
1164
1197
  if (this.method === this.function)
1165
1198
  this.method = '';
1199
+ // const func = c.getFunction()
1166
1200
  this.pos = [call.getEnclosingLineNumber() ?? 0, call.getEnclosingColumnNumber() ?? 0];
1167
1201
  this.eval = call.getEvalOrigin() ?? '';
1168
1202
  this.source = call.getScriptNameOrSourceURL() ?? '';
@@ -1209,18 +1243,34 @@ var $;
1209
1243
  "use strict";
1210
1244
  var $;
1211
1245
  (function ($) {
1246
+ /**
1247
+ * Argument must be Truthy
1248
+ * @deprecated use $mol_assert_equal instead
1249
+ */
1212
1250
  function $mol_assert_ok(value) {
1213
1251
  if (value)
1214
1252
  return;
1215
1253
  $mol_fail(new Error(`${value} ≠ true`));
1216
1254
  }
1217
1255
  $.$mol_assert_ok = $mol_assert_ok;
1256
+ /**
1257
+ * Argument must be Falsy
1258
+ * @deprecated use $mol_assert_equal instead
1259
+ */
1218
1260
  function $mol_assert_not(value) {
1219
1261
  if (!value)
1220
1262
  return;
1221
1263
  $mol_fail(new Error(`${value} ≠ false`));
1222
1264
  }
1223
1265
  $.$mol_assert_not = $mol_assert_not;
1266
+ /**
1267
+ * Handler must throw an error.
1268
+ * @example
1269
+ * $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } ) // Passes because throws error
1270
+ * $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } , 'Parse error' ) // Passes because throws right message
1271
+ * $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } , Error ) // Passes because throws right class
1272
+ * @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
1273
+ */
1224
1274
  function $mol_assert_fail(handler, ErrorRight) {
1225
1275
  const fail = $.$mol_fail;
1226
1276
  try {
@@ -1243,10 +1293,18 @@ var $;
1243
1293
  $mol_fail(new Error('Not failed', { cause: { expect: ErrorRight } }));
1244
1294
  }
1245
1295
  $.$mol_assert_fail = $mol_assert_fail;
1296
+ /** @deprecated Use $mol_assert_equal */
1246
1297
  function $mol_assert_like(...args) {
1247
1298
  $mol_assert_equal(...args);
1248
1299
  }
1249
1300
  $.$mol_assert_like = $mol_assert_like;
1301
+ /**
1302
+ * All arguments must not be structural equal to each other.
1303
+ * @example
1304
+ * $mol_assert_unique( 1 , 2 , 3 ) // Passes
1305
+ * $mol_assert_unique( 1 , 1 , 2 ) // Fails because 1 === 1
1306
+ * @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
1307
+ */
1250
1308
  function $mol_assert_unique(...args) {
1251
1309
  for (let i = 0; i < args.length; ++i) {
1252
1310
  for (let j = 0; j < args.length; ++j) {
@@ -1259,6 +1317,13 @@ var $;
1259
1317
  }
1260
1318
  }
1261
1319
  $.$mol_assert_unique = $mol_assert_unique;
1320
+ /**
1321
+ * All arguments must be structural equal each other.
1322
+ * @example
1323
+ * $mol_assert_like( [1] , [1] , [1] ) // Passes
1324
+ * $mol_assert_like( [1] , [1] , [2] ) // Fails because 1 !== 2
1325
+ * @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
1326
+ */
1262
1327
  function $mol_assert_equal(...args) {
1263
1328
  for (let i = 1; i < args.length; ++i) {
1264
1329
  if ($mol_compare_deep(args[0], args[i]))
@@ -1362,6 +1427,7 @@ var $;
1362
1427
  "use strict";
1363
1428
  var $;
1364
1429
  (function ($) {
1430
+ /** Log begin of collapsed group only when some logged inside, returns func to close group */
1365
1431
  function $mol_log3_area_lazy(event) {
1366
1432
  const self = this.$;
1367
1433
  const stack = self.$mol_log3_stack;