mol_schema 0.0.22 → 0.0.23
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/README.md +14 -14
- package/node.d.ts +286 -136
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +297 -49
- package/node.js.map +1 -1
- package/node.mjs +297 -49
- package/node.test.js +485 -230
- package/node.test.js.map +1 -1
- package/package.json +11 -2
- package/web.d.ts +286 -136
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +297 -49
- package/web.js.map +1 -1
- package/web.mjs +297 -49
- package/web.test.js +254 -15
- package/web.test.js.map +1 -1
package/node.mjs
CHANGED
|
@@ -210,6 +210,241 @@ var $;
|
|
|
210
210
|
$.$mol_schema_string = $mol_schema_string;
|
|
211
211
|
})($ || ($ = {}));
|
|
212
212
|
|
|
213
|
+
;
|
|
214
|
+
"use strict";
|
|
215
|
+
var $;
|
|
216
|
+
(function ($) {
|
|
217
|
+
$.$mol_ambient_ref = Symbol('$mol_ambient_ref');
|
|
218
|
+
function $mol_ambient(overrides) {
|
|
219
|
+
return Object.setPrototypeOf(overrides, this || $);
|
|
220
|
+
}
|
|
221
|
+
$.$mol_ambient = $mol_ambient;
|
|
222
|
+
})($ || ($ = {}));
|
|
223
|
+
|
|
224
|
+
;
|
|
225
|
+
"use strict";
|
|
226
|
+
var $;
|
|
227
|
+
(function ($) {
|
|
228
|
+
const instances = new WeakSet();
|
|
229
|
+
/**
|
|
230
|
+
* Proxy that delegates all to lazy returned target.
|
|
231
|
+
*
|
|
232
|
+
* $mol_delegate( Array.prototype , ()=> fetch_array() )
|
|
233
|
+
*/
|
|
234
|
+
function $mol_delegate(proto, target) {
|
|
235
|
+
const proxy = new Proxy(proto, {
|
|
236
|
+
get: (_, field) => {
|
|
237
|
+
const obj = target();
|
|
238
|
+
let val = Reflect.get(obj, field);
|
|
239
|
+
if (typeof val === 'function') {
|
|
240
|
+
val = val.bind(obj);
|
|
241
|
+
}
|
|
242
|
+
return val;
|
|
243
|
+
},
|
|
244
|
+
has: (_, field) => Reflect.has(target(), field),
|
|
245
|
+
set: (_, field, value) => Reflect.set(target(), field, value),
|
|
246
|
+
getOwnPropertyDescriptor: (_, field) => Reflect.getOwnPropertyDescriptor(target(), field),
|
|
247
|
+
ownKeys: () => Reflect.ownKeys(target()),
|
|
248
|
+
getPrototypeOf: () => Reflect.getPrototypeOf(target()),
|
|
249
|
+
setPrototypeOf: (_, donor) => Reflect.setPrototypeOf(target(), donor),
|
|
250
|
+
isExtensible: () => Reflect.isExtensible(target()),
|
|
251
|
+
preventExtensions: () => Reflect.preventExtensions(target()),
|
|
252
|
+
apply: (_, self, args) => Reflect.apply(target(), self, args),
|
|
253
|
+
construct: (_, args, retarget) => Reflect.construct(target(), args, retarget),
|
|
254
|
+
defineProperty: (_, field, descr) => Reflect.defineProperty(target(), field, descr),
|
|
255
|
+
deleteProperty: (_, field) => Reflect.deleteProperty(target(), field),
|
|
256
|
+
});
|
|
257
|
+
instances.add(proxy);
|
|
258
|
+
return proxy;
|
|
259
|
+
}
|
|
260
|
+
$.$mol_delegate = $mol_delegate;
|
|
261
|
+
Reflect.defineProperty($mol_delegate, Symbol.hasInstance, {
|
|
262
|
+
value: (obj) => instances.has(obj),
|
|
263
|
+
});
|
|
264
|
+
})($ || ($ = {}));
|
|
265
|
+
|
|
266
|
+
;
|
|
267
|
+
"use strict";
|
|
268
|
+
var $;
|
|
269
|
+
(function ($) {
|
|
270
|
+
$.$mol_owning_map = new WeakMap();
|
|
271
|
+
function $mol_owning_allow(having) {
|
|
272
|
+
try {
|
|
273
|
+
if (!having)
|
|
274
|
+
return false;
|
|
275
|
+
if (typeof having !== 'object' && typeof having !== 'function')
|
|
276
|
+
return false;
|
|
277
|
+
if (having instanceof $mol_delegate)
|
|
278
|
+
return false;
|
|
279
|
+
if (typeof having['destructor'] !== 'function')
|
|
280
|
+
return false;
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
$.$mol_owning_allow = $mol_owning_allow;
|
|
288
|
+
function $mol_owning_get(having, Owner) {
|
|
289
|
+
if (!$mol_owning_allow(having))
|
|
290
|
+
return null;
|
|
291
|
+
while (true) {
|
|
292
|
+
const owner = $.$mol_owning_map.get(having);
|
|
293
|
+
if (!owner)
|
|
294
|
+
return owner;
|
|
295
|
+
if (!Owner)
|
|
296
|
+
return owner;
|
|
297
|
+
if (owner instanceof Owner)
|
|
298
|
+
return owner;
|
|
299
|
+
having = owner;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
$.$mol_owning_get = $mol_owning_get;
|
|
303
|
+
function $mol_owning_check(owner, having) {
|
|
304
|
+
if (!$mol_owning_allow(having))
|
|
305
|
+
return false;
|
|
306
|
+
if ($.$mol_owning_map.get(having) !== owner)
|
|
307
|
+
return false;
|
|
308
|
+
return true;
|
|
309
|
+
}
|
|
310
|
+
$.$mol_owning_check = $mol_owning_check;
|
|
311
|
+
function $mol_owning_catch(owner, having) {
|
|
312
|
+
if (!$mol_owning_allow(having))
|
|
313
|
+
return false;
|
|
314
|
+
if ($.$mol_owning_map.get(having))
|
|
315
|
+
return false;
|
|
316
|
+
$.$mol_owning_map.set(having, owner);
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
$.$mol_owning_catch = $mol_owning_catch;
|
|
320
|
+
})($ || ($ = {}));
|
|
321
|
+
|
|
322
|
+
;
|
|
323
|
+
"use strict";
|
|
324
|
+
var $;
|
|
325
|
+
(function ($) {
|
|
326
|
+
function $mol_fail_hidden(error) {
|
|
327
|
+
throw error; /// Use 'Never Pause Here' breakpoint in DevTools or simply blackbox this script
|
|
328
|
+
}
|
|
329
|
+
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
330
|
+
})($ || ($ = {}));
|
|
331
|
+
|
|
332
|
+
;
|
|
333
|
+
"use strict";
|
|
334
|
+
|
|
335
|
+
;
|
|
336
|
+
"use strict";
|
|
337
|
+
var $;
|
|
338
|
+
(function ($) {
|
|
339
|
+
if (!Symbol.dispose)
|
|
340
|
+
Symbol.dispose = Symbol('Symbol.dispose');
|
|
341
|
+
class $mol_object2 {
|
|
342
|
+
static $ = $;
|
|
343
|
+
[Symbol.toStringTag];
|
|
344
|
+
[$mol_ambient_ref] = null;
|
|
345
|
+
get $() {
|
|
346
|
+
if (this[$mol_ambient_ref])
|
|
347
|
+
return this[$mol_ambient_ref];
|
|
348
|
+
const owner = $mol_owning_get(this);
|
|
349
|
+
return this[$mol_ambient_ref] = owner?.$ || this.constructor.$ || $mol_object2.$;
|
|
350
|
+
}
|
|
351
|
+
set $(next) {
|
|
352
|
+
if (this[$mol_ambient_ref])
|
|
353
|
+
$mol_fail_hidden(new Error('Context already defined'));
|
|
354
|
+
this[$mol_ambient_ref] = next;
|
|
355
|
+
}
|
|
356
|
+
static create(init) {
|
|
357
|
+
const obj = new this;
|
|
358
|
+
if (init)
|
|
359
|
+
init(obj);
|
|
360
|
+
return obj;
|
|
361
|
+
}
|
|
362
|
+
static [Symbol.toPrimitive]() {
|
|
363
|
+
return this.toString();
|
|
364
|
+
}
|
|
365
|
+
static toString() {
|
|
366
|
+
return this[Symbol.toStringTag] || this.$.$mol_func_name(this);
|
|
367
|
+
}
|
|
368
|
+
static toJSON() {
|
|
369
|
+
return this.toString();
|
|
370
|
+
}
|
|
371
|
+
static [$mol_key_handle]() {
|
|
372
|
+
return this.toString();
|
|
373
|
+
}
|
|
374
|
+
destructor() { }
|
|
375
|
+
static destructor() { }
|
|
376
|
+
[Symbol.dispose]() {
|
|
377
|
+
this.destructor();
|
|
378
|
+
}
|
|
379
|
+
//[ Symbol.toPrimitive ]( hint: string ) {
|
|
380
|
+
// return hint === 'number' ? this.valueOf() : this.toString()
|
|
381
|
+
//}
|
|
382
|
+
toString() {
|
|
383
|
+
return this[Symbol.toStringTag] || this.constructor.name + '<>';
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
$.$mol_object2 = $mol_object2;
|
|
387
|
+
})($ || ($ = {}));
|
|
388
|
+
|
|
389
|
+
;
|
|
390
|
+
"use strict";
|
|
391
|
+
var $;
|
|
392
|
+
(function ($) {
|
|
393
|
+
class $mol_wrapper extends $mol_object2 {
|
|
394
|
+
static wrap;
|
|
395
|
+
static run(task) {
|
|
396
|
+
return this.func(task)();
|
|
397
|
+
}
|
|
398
|
+
static func(func) {
|
|
399
|
+
return this.wrap(func);
|
|
400
|
+
}
|
|
401
|
+
static get class() {
|
|
402
|
+
return (Class) => {
|
|
403
|
+
const construct = (target, args) => new Class(...args);
|
|
404
|
+
const handler = {
|
|
405
|
+
construct: this.func(construct)
|
|
406
|
+
};
|
|
407
|
+
handler[Symbol.toStringTag] = Class.name + '#';
|
|
408
|
+
return new Proxy(Class, handler);
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
static get method() {
|
|
412
|
+
return (obj, name, descr = Reflect.getOwnPropertyDescriptor(obj, name)) => {
|
|
413
|
+
descr.value = this.func(descr.value);
|
|
414
|
+
return descr;
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
static get field() {
|
|
418
|
+
return (obj, name, descr = Reflect.getOwnPropertyDescriptor(obj, name)) => {
|
|
419
|
+
descr.get = descr.set = this.func(descr.get);
|
|
420
|
+
return descr;
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
$.$mol_wrapper = $mol_wrapper;
|
|
425
|
+
})($ || ($ = {}));
|
|
426
|
+
|
|
427
|
+
;
|
|
428
|
+
"use strict";
|
|
429
|
+
var $;
|
|
430
|
+
(function ($) {
|
|
431
|
+
class $mol_memo extends $mol_wrapper {
|
|
432
|
+
static wrap(task) {
|
|
433
|
+
const store = new WeakMap();
|
|
434
|
+
const fun = function (next) {
|
|
435
|
+
if (next === undefined && store.has(this ?? fun))
|
|
436
|
+
return store.get(this ?? fun);
|
|
437
|
+
const val = task.call(this, next) ?? next;
|
|
438
|
+
store.set(this ?? fun, val);
|
|
439
|
+
return val;
|
|
440
|
+
};
|
|
441
|
+
Reflect.defineProperty(fun, 'name', { value: task.name + ' ' });
|
|
442
|
+
return fun;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
$.$mol_memo = $mol_memo;
|
|
446
|
+
})($ || ($ = {}));
|
|
447
|
+
|
|
213
448
|
;
|
|
214
449
|
"use strict";
|
|
215
450
|
var $;
|
|
@@ -283,7 +518,32 @@ var $;
|
|
|
283
518
|
"use strict";
|
|
284
519
|
var $;
|
|
285
520
|
(function ($) {
|
|
286
|
-
|
|
521
|
+
class $mol_memo_key extends $mol_wrapper {
|
|
522
|
+
static wrap(task) {
|
|
523
|
+
const store = new WeakMap();
|
|
524
|
+
const fun = function (key, next) {
|
|
525
|
+
let store2 = store.get(this ?? fun);
|
|
526
|
+
if (!store2)
|
|
527
|
+
store.set(this ?? fun, store2 = new Map);
|
|
528
|
+
const key_str = $mol_key(key);
|
|
529
|
+
if (next === undefined && store2.has(key_str))
|
|
530
|
+
return store2.get(key_str);
|
|
531
|
+
const val = task.call(this, key, next) ?? next;
|
|
532
|
+
store2.set(key_str, val);
|
|
533
|
+
return val;
|
|
534
|
+
};
|
|
535
|
+
Reflect.defineProperty(fun, 'name', { value: task.name + ' ' });
|
|
536
|
+
return fun;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
$.$mol_memo_key = $mol_memo_key;
|
|
540
|
+
})($ || ($ = {}));
|
|
541
|
+
|
|
542
|
+
;
|
|
543
|
+
"use strict";
|
|
544
|
+
var $;
|
|
545
|
+
(function ($) {
|
|
546
|
+
$.$mol_schema_pattern = $mol_memo_key.func(function $mol_schema_pattern(Pattern) {
|
|
287
547
|
return class $mol_schema_pattern_ extends $mol_schema_string {
|
|
288
548
|
static Pattern = Pattern;
|
|
289
549
|
static toString() {
|
|
@@ -301,15 +561,14 @@ var $;
|
|
|
301
561
|
}
|
|
302
562
|
static default = '';
|
|
303
563
|
};
|
|
304
|
-
}
|
|
305
|
-
$.$mol_schema_pattern = $mol_schema_pattern;
|
|
564
|
+
});
|
|
306
565
|
})($ || ($ = {}));
|
|
307
566
|
|
|
308
567
|
;
|
|
309
568
|
"use strict";
|
|
310
569
|
var $;
|
|
311
570
|
(function ($) {
|
|
312
|
-
function $mol_schema_instance(Class, ...args) {
|
|
571
|
+
$.$mol_schema_instance = $mol_memo_key.func(function $mol_schema_instance(Class, ...args) {
|
|
313
572
|
class $mol_schema_instance_ extends $mol_schema_any {
|
|
314
573
|
static Class = Class;
|
|
315
574
|
static toString() {
|
|
@@ -327,8 +586,7 @@ var $;
|
|
|
327
586
|
return ((Class[Symbol.hasInstance] === $mol_schema_any[Symbol.hasInstance])
|
|
328
587
|
? Class
|
|
329
588
|
: $mol_schema_instance_);
|
|
330
|
-
}
|
|
331
|
-
$.$mol_schema_instance = $mol_schema_instance;
|
|
589
|
+
});
|
|
332
590
|
})($ || ($ = {}));
|
|
333
591
|
|
|
334
592
|
;
|
|
@@ -338,7 +596,7 @@ var $;
|
|
|
338
596
|
"use strict";
|
|
339
597
|
var $;
|
|
340
598
|
(function ($) {
|
|
341
|
-
function $mol_schema_every(Schemas) {
|
|
599
|
+
$.$mol_schema_every = $mol_memo_key.func(function $mol_schema_every(Schemas) {
|
|
342
600
|
return class $mol_schema_every_ extends $mol_schema_any {
|
|
343
601
|
static Schemas = Schemas;
|
|
344
602
|
static toString() {
|
|
@@ -359,50 +617,47 @@ var $;
|
|
|
359
617
|
}
|
|
360
618
|
static default = Schemas.find(Scheme => this.check(Scheme.default));
|
|
361
619
|
};
|
|
362
|
-
}
|
|
363
|
-
$.$mol_schema_every = $mol_schema_every;
|
|
620
|
+
});
|
|
364
621
|
})($ || ($ = {}));
|
|
365
622
|
|
|
366
623
|
;
|
|
367
624
|
"use strict";
|
|
368
625
|
var $;
|
|
369
626
|
(function ($) {
|
|
370
|
-
function $mol_schema_range(
|
|
627
|
+
$.$mol_schema_range = $mol_memo_key.func(function $mol_schema_range(Range) {
|
|
371
628
|
return class $mol_schema_range_ extends $mol_schema_any {
|
|
372
|
-
static
|
|
373
|
-
static Max = Max;
|
|
629
|
+
static Range = Range;
|
|
374
630
|
static toString() {
|
|
375
631
|
if (this !== $mol_schema_range_)
|
|
376
632
|
return super.toString();
|
|
377
|
-
return '$mol_schema_range<' + $mol_key(
|
|
633
|
+
return '$mol_schema_range<' + $mol_key(Range) + '>';
|
|
378
634
|
}
|
|
379
635
|
static guard(value) {
|
|
380
636
|
if (typeof value !== 'number' && typeof value !== 'bigint')
|
|
381
637
|
return $mol_fail(new TypeError('Uncomparable type', { cause: { value, schema: this } }));
|
|
382
|
-
if (!(value <=
|
|
638
|
+
if (!(value <= Range[1]))
|
|
383
639
|
return $mol_fail(new TypeError('Too large', { cause: { value, schema: this } }));
|
|
384
|
-
if (!(value >=
|
|
640
|
+
if (!(value >= Range[0]))
|
|
385
641
|
return $mol_fail(new TypeError('Too small', { cause: { value, schema: this } }));
|
|
386
642
|
return value;
|
|
387
643
|
}
|
|
388
644
|
static cast(val) {
|
|
389
|
-
if (val >
|
|
390
|
-
return
|
|
391
|
-
if (val >=
|
|
645
|
+
if (val > Range[1])
|
|
646
|
+
return Range[1];
|
|
647
|
+
if (val >= Range[0])
|
|
392
648
|
return val;
|
|
393
|
-
return
|
|
649
|
+
return Range[0];
|
|
394
650
|
}
|
|
395
|
-
static default =
|
|
651
|
+
static default = Range[0];
|
|
396
652
|
};
|
|
397
|
-
}
|
|
398
|
-
$.$mol_schema_range = $mol_schema_range;
|
|
653
|
+
});
|
|
399
654
|
})($ || ($ = {}));
|
|
400
655
|
|
|
401
656
|
;
|
|
402
657
|
"use strict";
|
|
403
658
|
var $;
|
|
404
659
|
(function ($) {
|
|
405
|
-
class $mol_schema_positive extends $mol_schema_range(0, Number.POSITIVE_INFINITY) {
|
|
660
|
+
class $mol_schema_positive extends $mol_schema_range([0, Number.POSITIVE_INFINITY]) {
|
|
406
661
|
}
|
|
407
662
|
$.$mol_schema_positive = $mol_schema_positive;
|
|
408
663
|
})($ || ($ = {}));
|
|
@@ -423,7 +678,7 @@ var $;
|
|
|
423
678
|
"use strict";
|
|
424
679
|
var $;
|
|
425
680
|
(function ($) {
|
|
426
|
-
function $mol_schema_enum(Options) {
|
|
681
|
+
$.$mol_schema_enum = $mol_memo_key.func(function $mol_schema_enum(Options) {
|
|
427
682
|
return class $mol_schema_enum_ extends $mol_schema_any {
|
|
428
683
|
static Options = Options;
|
|
429
684
|
static toString() {
|
|
@@ -443,15 +698,14 @@ var $;
|
|
|
443
698
|
}
|
|
444
699
|
static default = Options[0];
|
|
445
700
|
};
|
|
446
|
-
}
|
|
447
|
-
$.$mol_schema_enum = $mol_schema_enum;
|
|
701
|
+
});
|
|
448
702
|
})($ || ($ = {}));
|
|
449
703
|
|
|
450
704
|
;
|
|
451
705
|
"use strict";
|
|
452
706
|
var $;
|
|
453
707
|
(function ($) {
|
|
454
|
-
class $mol_schema_negative extends $mol_schema_range(Number.NEGATIVE_INFINITY, 0) {
|
|
708
|
+
class $mol_schema_negative extends $mol_schema_range([Number.NEGATIVE_INFINITY, 0]) {
|
|
455
709
|
}
|
|
456
710
|
$.$mol_schema_negative = $mol_schema_negative;
|
|
457
711
|
})($ || ($ = {}));
|
|
@@ -460,7 +714,7 @@ var $;
|
|
|
460
714
|
"use strict";
|
|
461
715
|
var $;
|
|
462
716
|
(function ($) {
|
|
463
|
-
function $mol_schema_some(Variants) {
|
|
717
|
+
$.$mol_schema_some = $mol_memo_key.func(function $mol_schema_some(Variants) {
|
|
464
718
|
return class $mol_schema_some_ extends $mol_schema_any {
|
|
465
719
|
static Variants = Variants;
|
|
466
720
|
static toString() {
|
|
@@ -490,15 +744,14 @@ var $;
|
|
|
490
744
|
}
|
|
491
745
|
static default = Variants[0].default;
|
|
492
746
|
};
|
|
493
|
-
}
|
|
494
|
-
$.$mol_schema_some = $mol_schema_some;
|
|
747
|
+
});
|
|
495
748
|
})($ || ($ = {}));
|
|
496
749
|
|
|
497
750
|
;
|
|
498
751
|
"use strict";
|
|
499
752
|
var $;
|
|
500
753
|
(function ($) {
|
|
501
|
-
function $mol_schema_maybe(Some) {
|
|
754
|
+
$.$mol_schema_maybe = $mol_memo_key.func(function $mol_schema_maybe(Some) {
|
|
502
755
|
return class $mol_schema_maybe_ extends $mol_schema_some([$mol_schema_enum([undefined, null]), Some]) {
|
|
503
756
|
static Some = Some;
|
|
504
757
|
static toString() {
|
|
@@ -507,15 +760,14 @@ var $;
|
|
|
507
760
|
return '$mol_schema_maybe<' + $mol_key(Some) + '>';
|
|
508
761
|
}
|
|
509
762
|
};
|
|
510
|
-
}
|
|
511
|
-
$.$mol_schema_maybe = $mol_schema_maybe;
|
|
763
|
+
});
|
|
512
764
|
})($ || ($ = {}));
|
|
513
765
|
|
|
514
766
|
;
|
|
515
767
|
"use strict";
|
|
516
768
|
var $;
|
|
517
769
|
(function ($) {
|
|
518
|
-
function $mol_schema_list(Item) {
|
|
770
|
+
$.$mol_schema_list = $mol_memo_key.func(function $mol_schema_list(Item) {
|
|
519
771
|
return class $mol_schema_list_ extends $mol_schema_any {
|
|
520
772
|
static Item = Item;
|
|
521
773
|
static toString() {
|
|
@@ -543,22 +795,20 @@ var $;
|
|
|
543
795
|
}
|
|
544
796
|
static default = [];
|
|
545
797
|
};
|
|
546
|
-
}
|
|
547
|
-
$.$mol_schema_list = $mol_schema_list;
|
|
798
|
+
});
|
|
548
799
|
})($ || ($ = {}));
|
|
549
800
|
|
|
550
801
|
;
|
|
551
802
|
"use strict";
|
|
552
803
|
var $;
|
|
553
804
|
(function ($) {
|
|
554
|
-
function $mol_schema_dict(
|
|
805
|
+
$.$mol_schema_dict = $mol_memo_key.func(function $mol_schema_dict(Pair) {
|
|
555
806
|
return class $mol_schema_dict_ extends $mol_schema_any {
|
|
556
|
-
static
|
|
557
|
-
static Val = Val;
|
|
807
|
+
static Pair = Pair;
|
|
558
808
|
static toString() {
|
|
559
809
|
if (this !== $mol_schema_dict_)
|
|
560
810
|
return super.toString();
|
|
561
|
-
return '$mol_schema_dict<' + $mol_key(
|
|
811
|
+
return '$mol_schema_dict<' + $mol_key(Pair) + '>';
|
|
562
812
|
}
|
|
563
813
|
static guard(value) {
|
|
564
814
|
if (Object.getPrototypeOf(Object.getPrototypeOf(value))) {
|
|
@@ -566,13 +816,13 @@ var $;
|
|
|
566
816
|
}
|
|
567
817
|
for (const key in value) {
|
|
568
818
|
try {
|
|
569
|
-
|
|
819
|
+
Pair[0].guard(key);
|
|
570
820
|
}
|
|
571
821
|
catch (error) {
|
|
572
822
|
return $mol_fail(new TypeError('Wrong key', { cause: { key, error, value, schema: this } }));
|
|
573
823
|
}
|
|
574
824
|
try {
|
|
575
|
-
|
|
825
|
+
Pair[1].guard(value[key]);
|
|
576
826
|
}
|
|
577
827
|
catch (error) {
|
|
578
828
|
return $mol_fail(new TypeError('Wrong val', { cause: { key, error, value, schema: this } }));
|
|
@@ -585,23 +835,22 @@ var $;
|
|
|
585
835
|
return this.default;
|
|
586
836
|
const res = {};
|
|
587
837
|
for (const key in value) {
|
|
588
|
-
if (!
|
|
838
|
+
if (!Pair[0].check(key))
|
|
589
839
|
continue;
|
|
590
|
-
res[key] =
|
|
840
|
+
res[key] = Pair[1].cast(value[key]);
|
|
591
841
|
}
|
|
592
842
|
return res;
|
|
593
843
|
}
|
|
594
844
|
static default = {};
|
|
595
845
|
};
|
|
596
|
-
}
|
|
597
|
-
$.$mol_schema_dict = $mol_schema_dict;
|
|
846
|
+
});
|
|
598
847
|
})($ || ($ = {}));
|
|
599
848
|
|
|
600
849
|
;
|
|
601
850
|
"use strict";
|
|
602
851
|
var $;
|
|
603
852
|
(function ($) {
|
|
604
|
-
function $mol_schema_record(Fields) {
|
|
853
|
+
$.$mol_schema_record = $mol_memo_key.func(function $mol_schema_record(Fields) {
|
|
605
854
|
return class $mol_schema_record_ extends $mol_schema_any {
|
|
606
855
|
static Fields = Fields;
|
|
607
856
|
static toString() {
|
|
@@ -633,8 +882,7 @@ var $;
|
|
|
633
882
|
}
|
|
634
883
|
static default = Object.fromEntries(Object.entries(Fields).map(([field, Field]) => [field, Field.default]));
|
|
635
884
|
};
|
|
636
|
-
}
|
|
637
|
-
$.$mol_schema_record = $mol_schema_record;
|
|
885
|
+
});
|
|
638
886
|
})($ || ($ = {}));
|
|
639
887
|
|
|
640
888
|
;
|