mol_conform 0.0.262 → 0.0.264
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.test.js +246 -9
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +67 -1
- package/web.test.js.map +1 -1
package/package.json
CHANGED
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
|
})($ || ($ = {}));
|
|
@@ -244,6 +244,12 @@ var $;
|
|
|
244
244
|
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
245
245
|
};
|
|
246
246
|
$.$mol_jsx_frag = '';
|
|
247
|
+
/**
|
|
248
|
+
* JSX adapter that makes DOM tree.
|
|
249
|
+
* Generates global unique ids for every DOM-element by components tree with ids.
|
|
250
|
+
* Ensures all local ids are unique.
|
|
251
|
+
* Can reuse an existing nodes by GUIDs when used inside [`mol_jsx_attach`](https://github.com/hyoo-ru/mam_mol/tree/master/jsx/attach).
|
|
252
|
+
*/
|
|
247
253
|
function $mol_jsx(Elem, props, ...childNodes) {
|
|
248
254
|
const id = props && props.id || '';
|
|
249
255
|
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
|
@@ -354,6 +360,8 @@ var $;
|
|
|
354
360
|
|
|
355
361
|
;
|
|
356
362
|
"use strict";
|
|
363
|
+
/** @jsx $mol_jsx */
|
|
364
|
+
/** @jsxFrag $mol_jsx_frag */
|
|
357
365
|
var $;
|
|
358
366
|
(function ($) {
|
|
359
367
|
$mol_test({
|
|
@@ -459,6 +467,7 @@ var $;
|
|
|
459
467
|
"use strict";
|
|
460
468
|
var $;
|
|
461
469
|
(function ($) {
|
|
470
|
+
/** Generates unique identifier. */
|
|
462
471
|
function $mol_guid(length = 8, exists = () => false) {
|
|
463
472
|
for (;;) {
|
|
464
473
|
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
@@ -474,6 +483,7 @@ var $;
|
|
|
474
483
|
"use strict";
|
|
475
484
|
var $;
|
|
476
485
|
(function ($) {
|
|
486
|
+
/** Lazy computed lists with native Array interface. $mol_range2_array is mutable but all derived ranges are immutable. */
|
|
477
487
|
function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
|
|
478
488
|
const source = typeof item === 'function' ? new $mol_range2_array() : item;
|
|
479
489
|
if (typeof item !== 'function') {
|
|
@@ -522,6 +532,7 @@ var $;
|
|
|
522
532
|
}
|
|
523
533
|
$.$mol_range2 = $mol_range2;
|
|
524
534
|
class $mol_range2_array extends Array {
|
|
535
|
+
// Lazy
|
|
525
536
|
concat(...tail) {
|
|
526
537
|
if (tail.length === 0)
|
|
527
538
|
return this;
|
|
@@ -533,6 +544,7 @@ var $;
|
|
|
533
544
|
}
|
|
534
545
|
return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
|
|
535
546
|
}
|
|
547
|
+
// Lazy
|
|
536
548
|
filter(check, context) {
|
|
537
549
|
const filtered = [];
|
|
538
550
|
let cursor = -1;
|
|
@@ -545,13 +557,16 @@ var $;
|
|
|
545
557
|
return filtered[index];
|
|
546
558
|
}, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
|
|
547
559
|
}
|
|
560
|
+
// Diligent
|
|
548
561
|
forEach(proceed, context) {
|
|
549
562
|
for (let [key, value] of this.entries())
|
|
550
563
|
proceed.call(context, value, key, this);
|
|
551
564
|
}
|
|
565
|
+
// Lazy
|
|
552
566
|
map(proceed, context) {
|
|
553
567
|
return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
|
|
554
568
|
}
|
|
569
|
+
// Diligent
|
|
555
570
|
reduce(merge, result) {
|
|
556
571
|
let index = 0;
|
|
557
572
|
if (arguments.length === 1) {
|
|
@@ -562,12 +577,15 @@ var $;
|
|
|
562
577
|
}
|
|
563
578
|
return result;
|
|
564
579
|
}
|
|
580
|
+
// Lazy
|
|
565
581
|
toReversed() {
|
|
566
582
|
return $mol_range2(index => this[this.length - 1 - index], () => this.length);
|
|
567
583
|
}
|
|
584
|
+
// Lazy
|
|
568
585
|
slice(from = 0, to = this.length) {
|
|
569
586
|
return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
|
|
570
587
|
}
|
|
588
|
+
// Lazy
|
|
571
589
|
some(check, context) {
|
|
572
590
|
for (let index = 0; index < this.length; ++index) {
|
|
573
591
|
if (check.call(context, this[index], index, this))
|
|
@@ -763,6 +781,10 @@ var $;
|
|
|
763
781
|
var $;
|
|
764
782
|
(function ($) {
|
|
765
783
|
$.$mol_compare_deep_cache = new WeakMap();
|
|
784
|
+
/**
|
|
785
|
+
* Deeply compares two values. Returns true if equal.
|
|
786
|
+
* Define `Symbol.toPrimitive` to customize.
|
|
787
|
+
*/
|
|
766
788
|
function $mol_compare_deep(left, right) {
|
|
767
789
|
if (Object.is(left, right))
|
|
768
790
|
return true;
|
|
@@ -900,6 +922,7 @@ var $;
|
|
|
900
922
|
|
|
901
923
|
;
|
|
902
924
|
"use strict";
|
|
925
|
+
/** @jsx $mol_jsx */
|
|
903
926
|
var $;
|
|
904
927
|
(function ($) {
|
|
905
928
|
$mol_test({
|
|
@@ -961,6 +984,7 @@ var $;
|
|
|
961
984
|
const obj3_copy = { test: 3, obj2: obj2_copy };
|
|
962
985
|
obj1.obj3 = obj3;
|
|
963
986
|
obj1_copy.obj3 = obj3_copy;
|
|
987
|
+
// warmup cache
|
|
964
988
|
$mol_assert_not($mol_compare_deep(obj1, {}));
|
|
965
989
|
$mol_assert_not($mol_compare_deep(obj2, {}));
|
|
966
990
|
$mol_assert_not($mol_compare_deep(obj3, {}));
|
|
@@ -1030,6 +1054,7 @@ var $;
|
|
|
1030
1054
|
"use strict";
|
|
1031
1055
|
var $;
|
|
1032
1056
|
(function ($) {
|
|
1057
|
+
// https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview#
|
|
1033
1058
|
$['devtoolsFormatters'] ||= [];
|
|
1034
1059
|
function $mol_dev_format_register(config) {
|
|
1035
1060
|
$['devtoolsFormatters'].push(config);
|
|
@@ -1081,6 +1106,7 @@ var $;
|
|
|
1081
1106
|
return false;
|
|
1082
1107
|
if (!val)
|
|
1083
1108
|
return false;
|
|
1109
|
+
// if( Error.isError( val ) ) true
|
|
1084
1110
|
if (val[$.$mol_dev_format_body])
|
|
1085
1111
|
return true;
|
|
1086
1112
|
return false;
|
|
@@ -1098,12 +1124,16 @@ var $;
|
|
|
1098
1124
|
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
1099
1125
|
}
|
|
1100
1126
|
}
|
|
1127
|
+
// if( Error.isError( val ) ) {
|
|
1128
|
+
// return $mol_dev_format_native( val )
|
|
1129
|
+
// }
|
|
1101
1130
|
return null;
|
|
1102
1131
|
},
|
|
1103
1132
|
});
|
|
1104
1133
|
function $mol_dev_format_native(obj) {
|
|
1105
1134
|
if (typeof obj === 'undefined')
|
|
1106
1135
|
return $.$mol_dev_format_shade('undefined');
|
|
1136
|
+
// if( ![ 'object', 'function', 'symbol' ].includes( typeof obj ) ) return obj
|
|
1107
1137
|
return [
|
|
1108
1138
|
'object',
|
|
1109
1139
|
{
|
|
@@ -1161,6 +1191,9 @@ var $;
|
|
|
1161
1191
|
'margin-left': '13px'
|
|
1162
1192
|
});
|
|
1163
1193
|
class Stack extends Array {
|
|
1194
|
+
// [ Symbol.toPrimitive ]() {
|
|
1195
|
+
// return this.toString()
|
|
1196
|
+
// }
|
|
1164
1197
|
toString() {
|
|
1165
1198
|
return this.join('\n');
|
|
1166
1199
|
}
|
|
@@ -1183,6 +1216,7 @@ var $;
|
|
|
1183
1216
|
this.method = call.getMethodName() ?? '';
|
|
1184
1217
|
if (this.method === this.function)
|
|
1185
1218
|
this.method = '';
|
|
1219
|
+
// const func = c.getFunction()
|
|
1186
1220
|
this.pos = [call.getEnclosingLineNumber() ?? 0, call.getEnclosingColumnNumber() ?? 0];
|
|
1187
1221
|
this.eval = call.getEvalOrigin() ?? '';
|
|
1188
1222
|
this.source = call.getScriptNameOrSourceURL() ?? '';
|
|
@@ -1229,18 +1263,34 @@ var $;
|
|
|
1229
1263
|
"use strict";
|
|
1230
1264
|
var $;
|
|
1231
1265
|
(function ($) {
|
|
1266
|
+
/**
|
|
1267
|
+
* Argument must be Truthy
|
|
1268
|
+
* @deprecated use $mol_assert_equal instead
|
|
1269
|
+
*/
|
|
1232
1270
|
function $mol_assert_ok(value) {
|
|
1233
1271
|
if (value)
|
|
1234
1272
|
return;
|
|
1235
1273
|
$mol_fail(new Error(`${value} ≠ true`));
|
|
1236
1274
|
}
|
|
1237
1275
|
$.$mol_assert_ok = $mol_assert_ok;
|
|
1276
|
+
/**
|
|
1277
|
+
* Argument must be Falsy
|
|
1278
|
+
* @deprecated use $mol_assert_equal instead
|
|
1279
|
+
*/
|
|
1238
1280
|
function $mol_assert_not(value) {
|
|
1239
1281
|
if (!value)
|
|
1240
1282
|
return;
|
|
1241
1283
|
$mol_fail(new Error(`${value} ≠ false`));
|
|
1242
1284
|
}
|
|
1243
1285
|
$.$mol_assert_not = $mol_assert_not;
|
|
1286
|
+
/**
|
|
1287
|
+
* Handler must throw an error.
|
|
1288
|
+
* @example
|
|
1289
|
+
* $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } ) // Passes because throws error
|
|
1290
|
+
* $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } , 'Parse error' ) // Passes because throws right message
|
|
1291
|
+
* $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } , Error ) // Passes because throws right class
|
|
1292
|
+
* @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
|
|
1293
|
+
*/
|
|
1244
1294
|
function $mol_assert_fail(handler, ErrorRight) {
|
|
1245
1295
|
const fail = $.$mol_fail;
|
|
1246
1296
|
try {
|
|
@@ -1263,10 +1313,18 @@ var $;
|
|
|
1263
1313
|
$mol_fail(new Error('Not failed', { cause: { expect: ErrorRight } }));
|
|
1264
1314
|
}
|
|
1265
1315
|
$.$mol_assert_fail = $mol_assert_fail;
|
|
1316
|
+
/** @deprecated Use $mol_assert_equal */
|
|
1266
1317
|
function $mol_assert_like(...args) {
|
|
1267
1318
|
$mol_assert_equal(...args);
|
|
1268
1319
|
}
|
|
1269
1320
|
$.$mol_assert_like = $mol_assert_like;
|
|
1321
|
+
/**
|
|
1322
|
+
* All arguments must not be structural equal to each other.
|
|
1323
|
+
* @example
|
|
1324
|
+
* $mol_assert_unique( 1 , 2 , 3 ) // Passes
|
|
1325
|
+
* $mol_assert_unique( 1 , 1 , 2 ) // Fails because 1 === 1
|
|
1326
|
+
* @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
|
|
1327
|
+
*/
|
|
1270
1328
|
function $mol_assert_unique(...args) {
|
|
1271
1329
|
for (let i = 0; i < args.length; ++i) {
|
|
1272
1330
|
for (let j = 0; j < args.length; ++j) {
|
|
@@ -1279,6 +1337,13 @@ var $;
|
|
|
1279
1337
|
}
|
|
1280
1338
|
}
|
|
1281
1339
|
$.$mol_assert_unique = $mol_assert_unique;
|
|
1340
|
+
/**
|
|
1341
|
+
* All arguments must be structural equal each other.
|
|
1342
|
+
* @example
|
|
1343
|
+
* $mol_assert_like( [1] , [1] , [1] ) // Passes
|
|
1344
|
+
* $mol_assert_like( [1] , [1] , [2] ) // Fails because 1 !== 2
|
|
1345
|
+
* @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
|
|
1346
|
+
*/
|
|
1282
1347
|
function $mol_assert_equal(...args) {
|
|
1283
1348
|
for (let i = 1; i < args.length; ++i) {
|
|
1284
1349
|
if ($mol_compare_deep(args[0], args[i]))
|
|
@@ -1331,6 +1396,7 @@ var $;
|
|
|
1331
1396
|
"use strict";
|
|
1332
1397
|
var $;
|
|
1333
1398
|
(function ($) {
|
|
1399
|
+
/** Log begin of collapsed group only when some logged inside, returns func to close group */
|
|
1334
1400
|
function $mol_log3_area_lazy(event) {
|
|
1335
1401
|
const self = this.$;
|
|
1336
1402
|
const stack = self.$mol_log3_stack;
|