mol_schema 0.0.11 → 0.0.13
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 +12 -0
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +9 -2
- package/node.js.map +1 -1
- package/node.mjs +9 -2
- package/node.test.js +255 -11
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +12 -0
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +9 -2
- package/web.js.map +1 -1
- package/web.mjs +9 -2
- package/web.test.js +67 -1
- package/web.test.js.map +1 -1
package/web.test.js
CHANGED
|
@@ -19,7 +19,7 @@ var $;
|
|
|
19
19
|
var $;
|
|
20
20
|
(function ($) {
|
|
21
21
|
function $mol_fail_hidden(error) {
|
|
22
|
-
throw error;
|
|
22
|
+
throw error; /// Use 'Never Pause Here' breakpoint in DevTools or simply blackbox this script
|
|
23
23
|
}
|
|
24
24
|
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
25
25
|
})($ || ($ = {}));
|
|
@@ -234,6 +234,12 @@ var $;
|
|
|
234
234
|
createDocumentFragment: () => $mol_dom_context.document.createDocumentFragment(),
|
|
235
235
|
};
|
|
236
236
|
$.$mol_jsx_frag = '';
|
|
237
|
+
/**
|
|
238
|
+
* JSX adapter that makes DOM tree.
|
|
239
|
+
* Generates global unique ids for every DOM-element by components tree with ids.
|
|
240
|
+
* Ensures all local ids are unique.
|
|
241
|
+
* Can reuse an existing nodes by GUIDs when used inside [`mol_jsx_attach`](https://github.com/hyoo-ru/mam_mol/tree/master/jsx/attach).
|
|
242
|
+
*/
|
|
237
243
|
function $mol_jsx(Elem, props, ...childNodes) {
|
|
238
244
|
const id = props && props.id || '';
|
|
239
245
|
const guid = id ? $.$mol_jsx_prefix ? $.$mol_jsx_prefix + '/' + id : id : $.$mol_jsx_prefix;
|
|
@@ -344,6 +350,8 @@ var $;
|
|
|
344
350
|
|
|
345
351
|
;
|
|
346
352
|
"use strict";
|
|
353
|
+
/** @jsx $mol_jsx */
|
|
354
|
+
/** @jsxFrag $mol_jsx_frag */
|
|
347
355
|
var $;
|
|
348
356
|
(function ($) {
|
|
349
357
|
$mol_test({
|
|
@@ -449,6 +457,7 @@ var $;
|
|
|
449
457
|
"use strict";
|
|
450
458
|
var $;
|
|
451
459
|
(function ($) {
|
|
460
|
+
/** Lazy computed lists with native Array interface. $mol_range2_array is mutable but all derived ranges are immutable. */
|
|
452
461
|
function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
|
|
453
462
|
const source = typeof item === 'function' ? new $mol_range2_array() : item;
|
|
454
463
|
if (typeof item !== 'function') {
|
|
@@ -497,6 +506,7 @@ var $;
|
|
|
497
506
|
}
|
|
498
507
|
$.$mol_range2 = $mol_range2;
|
|
499
508
|
class $mol_range2_array extends Array {
|
|
509
|
+
// Lazy
|
|
500
510
|
concat(...tail) {
|
|
501
511
|
if (tail.length === 0)
|
|
502
512
|
return this;
|
|
@@ -508,6 +518,7 @@ var $;
|
|
|
508
518
|
}
|
|
509
519
|
return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
|
|
510
520
|
}
|
|
521
|
+
// Lazy
|
|
511
522
|
filter(check, context) {
|
|
512
523
|
const filtered = [];
|
|
513
524
|
let cursor = -1;
|
|
@@ -520,13 +531,16 @@ var $;
|
|
|
520
531
|
return filtered[index];
|
|
521
532
|
}, () => cursor < this.length ? Number.POSITIVE_INFINITY : filtered.length);
|
|
522
533
|
}
|
|
534
|
+
// Diligent
|
|
523
535
|
forEach(proceed, context) {
|
|
524
536
|
for (let [key, value] of this.entries())
|
|
525
537
|
proceed.call(context, value, key, this);
|
|
526
538
|
}
|
|
539
|
+
// Lazy
|
|
527
540
|
map(proceed, context) {
|
|
528
541
|
return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
|
|
529
542
|
}
|
|
543
|
+
// Diligent
|
|
530
544
|
reduce(merge, result) {
|
|
531
545
|
let index = 0;
|
|
532
546
|
if (arguments.length === 1) {
|
|
@@ -537,12 +551,15 @@ var $;
|
|
|
537
551
|
}
|
|
538
552
|
return result;
|
|
539
553
|
}
|
|
554
|
+
// Lazy
|
|
540
555
|
toReversed() {
|
|
541
556
|
return $mol_range2(index => this[this.length - 1 - index], () => this.length);
|
|
542
557
|
}
|
|
558
|
+
// Lazy
|
|
543
559
|
slice(from = 0, to = this.length) {
|
|
544
560
|
return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
|
|
545
561
|
}
|
|
562
|
+
// Lazy
|
|
546
563
|
some(check, context) {
|
|
547
564
|
for (let index = 0; index < this.length; ++index) {
|
|
548
565
|
if (check.call(context, this[index], index, this))
|
|
@@ -738,6 +755,10 @@ var $;
|
|
|
738
755
|
var $;
|
|
739
756
|
(function ($) {
|
|
740
757
|
$.$mol_compare_deep_cache = new WeakMap();
|
|
758
|
+
/**
|
|
759
|
+
* Deeply compares two values. Returns true if equal.
|
|
760
|
+
* Define `Symbol.toPrimitive` to customize.
|
|
761
|
+
*/
|
|
741
762
|
function $mol_compare_deep(left, right) {
|
|
742
763
|
if (Object.is(left, right))
|
|
743
764
|
return true;
|
|
@@ -875,6 +896,7 @@ var $;
|
|
|
875
896
|
|
|
876
897
|
;
|
|
877
898
|
"use strict";
|
|
899
|
+
/** @jsx $mol_jsx */
|
|
878
900
|
var $;
|
|
879
901
|
(function ($) {
|
|
880
902
|
$mol_test({
|
|
@@ -936,6 +958,7 @@ var $;
|
|
|
936
958
|
const obj3_copy = { test: 3, obj2: obj2_copy };
|
|
937
959
|
obj1.obj3 = obj3;
|
|
938
960
|
obj1_copy.obj3 = obj3_copy;
|
|
961
|
+
// warmup cache
|
|
939
962
|
$mol_assert_not($mol_compare_deep(obj1, {}));
|
|
940
963
|
$mol_assert_not($mol_compare_deep(obj2, {}));
|
|
941
964
|
$mol_assert_not($mol_compare_deep(obj3, {}));
|
|
@@ -1005,6 +1028,7 @@ var $;
|
|
|
1005
1028
|
"use strict";
|
|
1006
1029
|
var $;
|
|
1007
1030
|
(function ($) {
|
|
1031
|
+
// https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview#
|
|
1008
1032
|
$['devtoolsFormatters'] ||= [];
|
|
1009
1033
|
function $mol_dev_format_register(config) {
|
|
1010
1034
|
$['devtoolsFormatters'].push(config);
|
|
@@ -1056,6 +1080,7 @@ var $;
|
|
|
1056
1080
|
return false;
|
|
1057
1081
|
if (!val)
|
|
1058
1082
|
return false;
|
|
1083
|
+
// if( Error.isError( val ) ) true
|
|
1059
1084
|
if (val[$.$mol_dev_format_body])
|
|
1060
1085
|
return true;
|
|
1061
1086
|
return false;
|
|
@@ -1073,12 +1098,16 @@ var $;
|
|
|
1073
1098
|
return $.$mol_dev_format_accent($mol_dev_format_native(val), '💨', $mol_dev_format_native(error), '');
|
|
1074
1099
|
}
|
|
1075
1100
|
}
|
|
1101
|
+
// if( Error.isError( val ) ) {
|
|
1102
|
+
// return $mol_dev_format_native( val )
|
|
1103
|
+
// }
|
|
1076
1104
|
return null;
|
|
1077
1105
|
},
|
|
1078
1106
|
});
|
|
1079
1107
|
function $mol_dev_format_native(obj) {
|
|
1080
1108
|
if (typeof obj === 'undefined')
|
|
1081
1109
|
return $.$mol_dev_format_shade('undefined');
|
|
1110
|
+
// if( ![ 'object', 'function', 'symbol' ].includes( typeof obj ) ) return obj
|
|
1082
1111
|
return [
|
|
1083
1112
|
'object',
|
|
1084
1113
|
{
|
|
@@ -1136,6 +1165,9 @@ var $;
|
|
|
1136
1165
|
'margin-left': '13px'
|
|
1137
1166
|
});
|
|
1138
1167
|
class Stack extends Array {
|
|
1168
|
+
// [ Symbol.toPrimitive ]() {
|
|
1169
|
+
// return this.toString()
|
|
1170
|
+
// }
|
|
1139
1171
|
toString() {
|
|
1140
1172
|
return this.join('\n');
|
|
1141
1173
|
}
|
|
@@ -1158,6 +1190,7 @@ var $;
|
|
|
1158
1190
|
this.method = call.getMethodName() ?? '';
|
|
1159
1191
|
if (this.method === this.function)
|
|
1160
1192
|
this.method = '';
|
|
1193
|
+
// const func = c.getFunction()
|
|
1161
1194
|
this.pos = [call.getEnclosingLineNumber() ?? 0, call.getEnclosingColumnNumber() ?? 0];
|
|
1162
1195
|
this.eval = call.getEvalOrigin() ?? '';
|
|
1163
1196
|
this.source = call.getScriptNameOrSourceURL() ?? '';
|
|
@@ -1204,18 +1237,34 @@ var $;
|
|
|
1204
1237
|
"use strict";
|
|
1205
1238
|
var $;
|
|
1206
1239
|
(function ($) {
|
|
1240
|
+
/**
|
|
1241
|
+
* Argument must be Truthy
|
|
1242
|
+
* @deprecated use $mol_assert_equal instead
|
|
1243
|
+
*/
|
|
1207
1244
|
function $mol_assert_ok(value) {
|
|
1208
1245
|
if (value)
|
|
1209
1246
|
return;
|
|
1210
1247
|
$mol_fail(new Error(`${value} ≠ true`));
|
|
1211
1248
|
}
|
|
1212
1249
|
$.$mol_assert_ok = $mol_assert_ok;
|
|
1250
|
+
/**
|
|
1251
|
+
* Argument must be Falsy
|
|
1252
|
+
* @deprecated use $mol_assert_equal instead
|
|
1253
|
+
*/
|
|
1213
1254
|
function $mol_assert_not(value) {
|
|
1214
1255
|
if (!value)
|
|
1215
1256
|
return;
|
|
1216
1257
|
$mol_fail(new Error(`${value} ≠ false`));
|
|
1217
1258
|
}
|
|
1218
1259
|
$.$mol_assert_not = $mol_assert_not;
|
|
1260
|
+
/**
|
|
1261
|
+
* Handler must throw an error.
|
|
1262
|
+
* @example
|
|
1263
|
+
* $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } ) // Passes because throws error
|
|
1264
|
+
* $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } , 'Parse error' ) // Passes because throws right message
|
|
1265
|
+
* $mol_assert_fail( ()=>{ throw new Error( 'Parse error' ) } , Error ) // Passes because throws right class
|
|
1266
|
+
* @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
|
|
1267
|
+
*/
|
|
1219
1268
|
function $mol_assert_fail(handler, ErrorRight) {
|
|
1220
1269
|
const fail = $.$mol_fail;
|
|
1221
1270
|
try {
|
|
@@ -1238,10 +1287,18 @@ var $;
|
|
|
1238
1287
|
$mol_fail(new Error('Not failed', { cause: { expect: ErrorRight } }));
|
|
1239
1288
|
}
|
|
1240
1289
|
$.$mol_assert_fail = $mol_assert_fail;
|
|
1290
|
+
/** @deprecated Use $mol_assert_equal */
|
|
1241
1291
|
function $mol_assert_like(...args) {
|
|
1242
1292
|
$mol_assert_equal(...args);
|
|
1243
1293
|
}
|
|
1244
1294
|
$.$mol_assert_like = $mol_assert_like;
|
|
1295
|
+
/**
|
|
1296
|
+
* All arguments must not be structural equal to each other.
|
|
1297
|
+
* @example
|
|
1298
|
+
* $mol_assert_unique( 1 , 2 , 3 ) // Passes
|
|
1299
|
+
* $mol_assert_unique( 1 , 1 , 2 ) // Fails because 1 === 1
|
|
1300
|
+
* @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
|
|
1301
|
+
*/
|
|
1245
1302
|
function $mol_assert_unique(...args) {
|
|
1246
1303
|
for (let i = 0; i < args.length; ++i) {
|
|
1247
1304
|
for (let j = 0; j < args.length; ++j) {
|
|
@@ -1254,6 +1311,13 @@ var $;
|
|
|
1254
1311
|
}
|
|
1255
1312
|
}
|
|
1256
1313
|
$.$mol_assert_unique = $mol_assert_unique;
|
|
1314
|
+
/**
|
|
1315
|
+
* All arguments must be structural equal each other.
|
|
1316
|
+
* @example
|
|
1317
|
+
* $mol_assert_like( [1] , [1] , [1] ) // Passes
|
|
1318
|
+
* $mol_assert_like( [1] , [1] , [2] ) // Fails because 1 !== 2
|
|
1319
|
+
* @see https://mol.hyoo.ru/#!section=docs/=9q9dv3_fgxjsf
|
|
1320
|
+
*/
|
|
1257
1321
|
function $mol_assert_equal(...args) {
|
|
1258
1322
|
for (let i = 1; i < args.length; ++i) {
|
|
1259
1323
|
if ($mol_compare_deep(args[0], args[i]))
|
|
@@ -1318,6 +1382,7 @@ var $;
|
|
|
1318
1382
|
|
|
1319
1383
|
;
|
|
1320
1384
|
"use strict";
|
|
1385
|
+
/** @jsx $mol_jsx */
|
|
1321
1386
|
var $;
|
|
1322
1387
|
(function ($) {
|
|
1323
1388
|
$mol_test({
|
|
@@ -1742,6 +1807,7 @@ var $;
|
|
|
1742
1807
|
"use strict";
|
|
1743
1808
|
var $;
|
|
1744
1809
|
(function ($) {
|
|
1810
|
+
/** Log begin of collapsed group only when some logged inside, returns func to close group */
|
|
1745
1811
|
function $mol_log3_area_lazy(event) {
|
|
1746
1812
|
const self = this.$;
|
|
1747
1813
|
const stack = self.$mol_log3_stack;
|