mol_schema 0.0.22 → 0.0.24
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 +22 -20
- package/node.d.ts +375 -343
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +470 -175
- package/node.js.map +1 -1
- package/node.meta.tree +4 -1
- package/node.mjs +470 -175
- package/node.test.js +718 -361
- package/node.test.js.map +1 -1
- package/package.json +17 -6
- package/web.d.ts +375 -343
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +470 -175
- package/web.js.map +1 -1
- package/web.meta.tree +4 -1
- package/web.mjs +470 -175
- package/web.test.js +316 -22
- package/web.test.js.map +1 -1
package/web.test.js
CHANGED
|
@@ -14,16 +14,6 @@ var $;
|
|
|
14
14
|
$.$mol_promise_like = $mol_promise_like;
|
|
15
15
|
})($ || ($ = {}));
|
|
16
16
|
|
|
17
|
-
;
|
|
18
|
-
"use strict";
|
|
19
|
-
var $;
|
|
20
|
-
(function ($) {
|
|
21
|
-
function $mol_fail_hidden(error) {
|
|
22
|
-
throw error; /// Use 'Never Pause Here' breakpoint in DevTools or simply blackbox this script
|
|
23
|
-
}
|
|
24
|
-
$.$mol_fail_hidden = $mol_fail_hidden;
|
|
25
|
-
})($ || ($ = {}));
|
|
26
|
-
|
|
27
17
|
;
|
|
28
18
|
"use strict";
|
|
29
19
|
var $;
|
|
@@ -1162,12 +1152,18 @@ var $;
|
|
|
1162
1152
|
'color': 'gray',
|
|
1163
1153
|
});
|
|
1164
1154
|
$.$mol_dev_format_indent = $.$mol_dev_format_div.bind(null, {
|
|
1165
|
-
'margin-
|
|
1155
|
+
'margin-inline-start': '13px'
|
|
1166
1156
|
});
|
|
1167
1157
|
class Stack extends Array {
|
|
1168
1158
|
// [ Symbol.toPrimitive ]() {
|
|
1169
1159
|
// return this.toString()
|
|
1170
1160
|
// }
|
|
1161
|
+
match(...args) {
|
|
1162
|
+
return this.toString().match(...args);
|
|
1163
|
+
}
|
|
1164
|
+
split(...args) {
|
|
1165
|
+
return this.toString().split(...args);
|
|
1166
|
+
}
|
|
1171
1167
|
toString() {
|
|
1172
1168
|
return this.join('\n');
|
|
1173
1169
|
}
|
|
@@ -1366,6 +1362,72 @@ var $;
|
|
|
1366
1362
|
});
|
|
1367
1363
|
})($ || ($ = {}));
|
|
1368
1364
|
|
|
1365
|
+
;
|
|
1366
|
+
"use strict";
|
|
1367
|
+
var $;
|
|
1368
|
+
(function ($) {
|
|
1369
|
+
$mol_test({
|
|
1370
|
+
'get'() {
|
|
1371
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1372
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
1373
|
+
},
|
|
1374
|
+
'has'() {
|
|
1375
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1376
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
1377
|
+
},
|
|
1378
|
+
'set'() {
|
|
1379
|
+
const target = { foo: 777 };
|
|
1380
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1381
|
+
proxy.foo = 123;
|
|
1382
|
+
$mol_assert_equal(target.foo, 123);
|
|
1383
|
+
},
|
|
1384
|
+
'getOwnPropertyDescriptor'() {
|
|
1385
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1386
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1387
|
+
value: 777,
|
|
1388
|
+
writable: true,
|
|
1389
|
+
enumerable: true,
|
|
1390
|
+
configurable: true,
|
|
1391
|
+
});
|
|
1392
|
+
},
|
|
1393
|
+
'ownKeys'() {
|
|
1394
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
1395
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1396
|
+
},
|
|
1397
|
+
'getPrototypeOf'() {
|
|
1398
|
+
class Foo {
|
|
1399
|
+
}
|
|
1400
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1401
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1402
|
+
},
|
|
1403
|
+
'setPrototypeOf'() {
|
|
1404
|
+
class Foo {
|
|
1405
|
+
}
|
|
1406
|
+
const target = {};
|
|
1407
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1408
|
+
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
1409
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
1410
|
+
},
|
|
1411
|
+
'instanceof'() {
|
|
1412
|
+
class Foo {
|
|
1413
|
+
}
|
|
1414
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1415
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1416
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1417
|
+
},
|
|
1418
|
+
'autobind'() {
|
|
1419
|
+
class Foo {
|
|
1420
|
+
}
|
|
1421
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1422
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1423
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1424
|
+
},
|
|
1425
|
+
});
|
|
1426
|
+
})($ || ($ = {}));
|
|
1427
|
+
|
|
1428
|
+
;
|
|
1429
|
+
"use strict";
|
|
1430
|
+
|
|
1369
1431
|
;
|
|
1370
1432
|
"use strict";
|
|
1371
1433
|
var $;
|
|
@@ -1380,6 +1442,149 @@ var $;
|
|
|
1380
1442
|
});
|
|
1381
1443
|
})($ || ($ = {}));
|
|
1382
1444
|
|
|
1445
|
+
;
|
|
1446
|
+
"use strict";
|
|
1447
|
+
var $;
|
|
1448
|
+
(function ($) {
|
|
1449
|
+
$mol_test({
|
|
1450
|
+
'run callback'() {
|
|
1451
|
+
class Plus1 extends $mol_wrapper {
|
|
1452
|
+
static wrap(task) {
|
|
1453
|
+
return function (...args) {
|
|
1454
|
+
return task.call(this, ...args) + 1;
|
|
1455
|
+
};
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
$mol_assert_equal(Plus1.run(() => 2), 3);
|
|
1459
|
+
},
|
|
1460
|
+
'wrap function'() {
|
|
1461
|
+
class Plus1 extends $mol_wrapper {
|
|
1462
|
+
static wrap(task) {
|
|
1463
|
+
return function (...args) {
|
|
1464
|
+
return task.call(this, ...args) + 1;
|
|
1465
|
+
};
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
const obj = {
|
|
1469
|
+
level: 2,
|
|
1470
|
+
pow: Plus1.func(function (a) {
|
|
1471
|
+
return a ** this.level;
|
|
1472
|
+
})
|
|
1473
|
+
};
|
|
1474
|
+
$mol_assert_equal(obj.pow(2), 5);
|
|
1475
|
+
},
|
|
1476
|
+
'decorate field getter'() {
|
|
1477
|
+
class Plus1 extends $mol_wrapper {
|
|
1478
|
+
static last = 0;
|
|
1479
|
+
static wrap(task) {
|
|
1480
|
+
return function (...args) {
|
|
1481
|
+
return Plus1.last = (task.call(this, ...args) || 0) + 1;
|
|
1482
|
+
};
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
class Foo {
|
|
1486
|
+
static get two() {
|
|
1487
|
+
return 1;
|
|
1488
|
+
}
|
|
1489
|
+
static set two(next) { }
|
|
1490
|
+
}
|
|
1491
|
+
__decorate([
|
|
1492
|
+
Plus1.field
|
|
1493
|
+
], Foo, "two", null);
|
|
1494
|
+
$mol_assert_equal(Foo.two, 2);
|
|
1495
|
+
Foo.two = 3;
|
|
1496
|
+
$mol_assert_equal(Plus1.last, 2);
|
|
1497
|
+
$mol_assert_equal(Foo.two, 2);
|
|
1498
|
+
},
|
|
1499
|
+
'decorate instance method'() {
|
|
1500
|
+
class Plus1 extends $mol_wrapper {
|
|
1501
|
+
static wrap(task) {
|
|
1502
|
+
return function (...args) {
|
|
1503
|
+
return task.call(this, ...args) + 1;
|
|
1504
|
+
};
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
class Foo1 {
|
|
1508
|
+
level = 2;
|
|
1509
|
+
pow(a) {
|
|
1510
|
+
return a ** this.level;
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
__decorate([
|
|
1514
|
+
Plus1.method
|
|
1515
|
+
], Foo1.prototype, "pow", null);
|
|
1516
|
+
const Foo2 = Foo1;
|
|
1517
|
+
const foo = new Foo2;
|
|
1518
|
+
$mol_assert_equal(foo.pow(2), 5);
|
|
1519
|
+
},
|
|
1520
|
+
'decorate static method'() {
|
|
1521
|
+
class Plus1 extends $mol_wrapper {
|
|
1522
|
+
static wrap(task) {
|
|
1523
|
+
return function (...args) {
|
|
1524
|
+
return task.call(this, ...args) + 1;
|
|
1525
|
+
};
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
class Foo {
|
|
1529
|
+
static level = 2;
|
|
1530
|
+
static pow(a) {
|
|
1531
|
+
return a ** this.level;
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
__decorate([
|
|
1535
|
+
Plus1.method
|
|
1536
|
+
], Foo, "pow", null);
|
|
1537
|
+
$mol_assert_equal(Foo.pow(2), 5);
|
|
1538
|
+
},
|
|
1539
|
+
'decorate class'() {
|
|
1540
|
+
class BarInc extends $mol_wrapper {
|
|
1541
|
+
static wrap(task) {
|
|
1542
|
+
return function (...args) {
|
|
1543
|
+
const foo = task.call(this, ...args);
|
|
1544
|
+
foo.bar++;
|
|
1545
|
+
return foo;
|
|
1546
|
+
};
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
let Foo = class Foo {
|
|
1550
|
+
bar;
|
|
1551
|
+
constructor(bar) {
|
|
1552
|
+
this.bar = bar;
|
|
1553
|
+
}
|
|
1554
|
+
};
|
|
1555
|
+
Foo = __decorate([
|
|
1556
|
+
BarInc.class
|
|
1557
|
+
], Foo);
|
|
1558
|
+
$mol_assert_equal(new Foo(2).bar, 3);
|
|
1559
|
+
},
|
|
1560
|
+
});
|
|
1561
|
+
})($ || ($ = {}));
|
|
1562
|
+
|
|
1563
|
+
;
|
|
1564
|
+
"use strict";
|
|
1565
|
+
var $;
|
|
1566
|
+
(function ($) {
|
|
1567
|
+
$mol_test({
|
|
1568
|
+
'memoize field'() {
|
|
1569
|
+
class Foo {
|
|
1570
|
+
static one = 1;
|
|
1571
|
+
static get two() {
|
|
1572
|
+
return ++this.one;
|
|
1573
|
+
}
|
|
1574
|
+
static set two(next) { }
|
|
1575
|
+
}
|
|
1576
|
+
__decorate([
|
|
1577
|
+
$mol_memo.field
|
|
1578
|
+
], Foo, "two", null);
|
|
1579
|
+
$mol_assert_equal(Foo.two, 2);
|
|
1580
|
+
$mol_assert_equal(Foo.two, 2);
|
|
1581
|
+
Foo.two = 3;
|
|
1582
|
+
$mol_assert_equal(Foo.two, 3);
|
|
1583
|
+
$mol_assert_equal(Foo.two, 3);
|
|
1584
|
+
},
|
|
1585
|
+
});
|
|
1586
|
+
})($ || ($ = {}));
|
|
1587
|
+
|
|
1383
1588
|
;
|
|
1384
1589
|
"use strict";
|
|
1385
1590
|
/** @jsx $mol_jsx */
|
|
@@ -1455,6 +1660,10 @@ var $;
|
|
|
1455
1660
|
var $$;
|
|
1456
1661
|
(function ($$) {
|
|
1457
1662
|
$mol_test({
|
|
1663
|
+
"Cache of enum schema"($) {
|
|
1664
|
+
$mol_assert_equal($mol_schema_enum(['foo']), $mol_schema_enum(['foo']));
|
|
1665
|
+
$mol_assert_unique($mol_schema_enum(['foo']), $mol_schema_enum(['bar']));
|
|
1666
|
+
},
|
|
1458
1667
|
"Enum options"($) {
|
|
1459
1668
|
const Config = $mol_schema_enum([123, 'foo']);
|
|
1460
1669
|
$mol_assert_equal('$mol_schema_enum<[123,"foo"]>', Config + '', $mol_key(Config));
|
|
@@ -1467,7 +1676,7 @@ var $;
|
|
|
1467
1676
|
$mol_assert_equal(Config.cast('foo'), 'foo');
|
|
1468
1677
|
$mol_assert_equal(Config.cast('bar'), 123);
|
|
1469
1678
|
$mol_assert_equal(123, Config.guard(123));
|
|
1470
|
-
$mol_assert_fail(() => Config.guard(321), '
|
|
1679
|
+
$mol_assert_fail(() => Config.guard(321), 'Wrong option');
|
|
1471
1680
|
},
|
|
1472
1681
|
});
|
|
1473
1682
|
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
@@ -1522,6 +1731,10 @@ var $;
|
|
|
1522
1731
|
var $$;
|
|
1523
1732
|
(function ($$) {
|
|
1524
1733
|
$mol_test({
|
|
1734
|
+
"Cache of some schema"($) {
|
|
1735
|
+
$mol_assert_equal($mol_schema_some([$mol_schema_float]), $mol_schema_some([$mol_schema_float]));
|
|
1736
|
+
$mol_assert_unique($mol_schema_some([$mol_schema_float]), $mol_schema_some([$mol_schema_string]));
|
|
1737
|
+
},
|
|
1525
1738
|
"Some variant"($) {
|
|
1526
1739
|
const Config = $mol_schema_some([$mol_schema_float, $mol_schema_string]);
|
|
1527
1740
|
$mol_assert_equal('$mol_schema_some<[$mol_schema_float,$mol_schema_string]>', Config + '');
|
|
@@ -1532,7 +1745,7 @@ var $;
|
|
|
1532
1745
|
$mol_assert_equal('foo', Config.cast('foo'));
|
|
1533
1746
|
$mol_assert_equal(Number.NaN, Config.cast(true));
|
|
1534
1747
|
$mol_assert_equal(123, Config.guard(123));
|
|
1535
|
-
$mol_assert_fail(() => Config.guard(false), '
|
|
1748
|
+
$mol_assert_fail(() => Config.guard(false), 'Wrong variant');
|
|
1536
1749
|
},
|
|
1537
1750
|
});
|
|
1538
1751
|
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
@@ -1545,6 +1758,10 @@ var $;
|
|
|
1545
1758
|
var $$;
|
|
1546
1759
|
(function ($$) {
|
|
1547
1760
|
$mol_test({
|
|
1761
|
+
"Cache of maybe schema"($) {
|
|
1762
|
+
$mol_assert_equal($mol_schema_maybe($mol_schema_float), $mol_schema_maybe($mol_schema_float));
|
|
1763
|
+
$mol_assert_unique($mol_schema_maybe($mol_schema_float), $mol_schema_maybe($mol_schema_string));
|
|
1764
|
+
},
|
|
1548
1765
|
"Optional value"($) {
|
|
1549
1766
|
const Config = $mol_schema_maybe($mol_schema_string);
|
|
1550
1767
|
$mol_assert_equal('$mol_schema_maybe<$mol_schema_string>', Config + '');
|
|
@@ -1555,9 +1772,9 @@ var $;
|
|
|
1555
1772
|
$mol_assert_equal('foo', Config.cast('foo'));
|
|
1556
1773
|
$mol_assert_equal(undefined, Config.cast(undefined));
|
|
1557
1774
|
$mol_assert_equal(null, Config.cast(null));
|
|
1558
|
-
$mol_assert_equal(
|
|
1775
|
+
$mol_assert_equal(null, Config.cast(0));
|
|
1559
1776
|
$mol_assert_equal('foo', Config.guard('foo'));
|
|
1560
|
-
$mol_assert_fail(() => Config.guard(123), '
|
|
1777
|
+
$mol_assert_fail(() => Config.guard(123), 'Wrong type');
|
|
1561
1778
|
},
|
|
1562
1779
|
});
|
|
1563
1780
|
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
@@ -1600,8 +1817,12 @@ var $;
|
|
|
1600
1817
|
var $$;
|
|
1601
1818
|
(function ($$) {
|
|
1602
1819
|
$mol_test({
|
|
1820
|
+
"Cache of range schema"($) {
|
|
1821
|
+
$mol_assert_equal($mol_schema_range([0, 1]), $mol_schema_range([0, 1]));
|
|
1822
|
+
$mol_assert_unique($mol_schema_range([0, 1]), $mol_schema_range([0, 2]));
|
|
1823
|
+
},
|
|
1603
1824
|
"Float range schema"($) {
|
|
1604
|
-
const Range = $mol_schema_range(4, 8);
|
|
1825
|
+
const Range = $mol_schema_range([4, 8]);
|
|
1605
1826
|
$mol_assert_equal(true, Range.check(5.5));
|
|
1606
1827
|
$mol_assert_equal(true, Range.check(4));
|
|
1607
1828
|
$mol_assert_equal(true, Range.check(8));
|
|
@@ -1626,9 +1847,13 @@ var $;
|
|
|
1626
1847
|
var $$;
|
|
1627
1848
|
(function ($$) {
|
|
1628
1849
|
$mol_test({
|
|
1850
|
+
"Cache of every schema"($) {
|
|
1851
|
+
$mol_assert_equal($mol_schema_every([$mol_schema_float]), $mol_schema_every([$mol_schema_float]));
|
|
1852
|
+
$mol_assert_unique($mol_schema_every([$mol_schema_float]), $mol_schema_every([$mol_schema_string]));
|
|
1853
|
+
},
|
|
1629
1854
|
"Range intersection"($) {
|
|
1630
|
-
const Narrow = $mol_schema_every([$mol_schema_integer, $mol_schema_range(1, 8), $mol_schema_range(4, 10)]);
|
|
1631
|
-
$mol_assert_equal('$mol_schema_every<[$mol_schema_integer,$mol_schema_range<1,8>,$mol_schema_range<4,10>]>', Narrow + '');
|
|
1855
|
+
const Narrow = $mol_schema_every([$mol_schema_integer, $mol_schema_range([1, 8]), $mol_schema_range([4, 10])]);
|
|
1856
|
+
$mol_assert_equal('$mol_schema_every<[$mol_schema_integer,$mol_schema_range<[1,8]>,$mol_schema_range<[4,10]>]>', Narrow + '');
|
|
1632
1857
|
$mol_assert_equal(true, Narrow.check(6));
|
|
1633
1858
|
$mol_assert_equal(true, Narrow.check(4));
|
|
1634
1859
|
$mol_assert_equal(true, Narrow.check(8));
|
|
@@ -1654,6 +1879,10 @@ var $;
|
|
|
1654
1879
|
var $$;
|
|
1655
1880
|
(function ($$) {
|
|
1656
1881
|
$mol_test({
|
|
1882
|
+
"Cache of list schema"($) {
|
|
1883
|
+
$mol_assert_equal($mol_schema_list($mol_schema_float), $mol_schema_list($mol_schema_float));
|
|
1884
|
+
$mol_assert_unique($mol_schema_list($mol_schema_float), $mol_schema_list($mol_schema_string));
|
|
1885
|
+
},
|
|
1657
1886
|
"Array schema"($) {
|
|
1658
1887
|
const Vector = $mol_schema_list($mol_schema_float);
|
|
1659
1888
|
$mol_assert_equal('$mol_schema_list<$mol_schema_float>', Vector + '');
|
|
@@ -1678,6 +1907,10 @@ var $;
|
|
|
1678
1907
|
var $$;
|
|
1679
1908
|
(function ($$) {
|
|
1680
1909
|
$mol_test({
|
|
1910
|
+
"Cache of pattern schema"($) {
|
|
1911
|
+
$mol_assert_equal($mol_schema_pattern(/foo/), $mol_schema_pattern(/foo/));
|
|
1912
|
+
$mol_assert_unique($mol_schema_pattern(/foo/), $mol_schema_pattern(/bar/));
|
|
1913
|
+
},
|
|
1681
1914
|
"String pattern schema"($) {
|
|
1682
1915
|
const Email = $mol_schema_pattern(/^.*@.*$/);
|
|
1683
1916
|
$mol_assert_equal('$mol_schema_pattern</^.*@.*$/>', Email + '', $mol_key(Email));
|
|
@@ -1721,8 +1954,12 @@ var $;
|
|
|
1721
1954
|
var $;
|
|
1722
1955
|
(function ($_1) {
|
|
1723
1956
|
$mol_test({
|
|
1957
|
+
"Cache of dict schema"($) {
|
|
1958
|
+
$mol_assert_equal($mol_schema_dict([$mol_schema_string, $mol_schema_float]), $mol_schema_dict([$mol_schema_string, $mol_schema_float]));
|
|
1959
|
+
$mol_assert_unique($mol_schema_dict([$mol_schema_string, $mol_schema_float]), $mol_schema_dict([$mol_schema_string, $mol_schema_string]));
|
|
1960
|
+
},
|
|
1724
1961
|
"Dictionary schema"($) {
|
|
1725
|
-
const Flags = $mol_schema_dict($mol_schema_pattern(/^[a-z]+$/), $mol_schema_boolean);
|
|
1962
|
+
const Flags = $mol_schema_dict([$mol_schema_pattern(/^[a-z]+$/), $mol_schema_boolean]);
|
|
1726
1963
|
$mol_assert_equal(true, Flags.check({}));
|
|
1727
1964
|
$mol_assert_equal(true, Flags.check({ foo: false }));
|
|
1728
1965
|
$mol_assert_equal(false, Flags.check({ f00: false }));
|
|
@@ -1745,6 +1982,10 @@ var $;
|
|
|
1745
1982
|
var $$;
|
|
1746
1983
|
(function ($$) {
|
|
1747
1984
|
$mol_test({
|
|
1985
|
+
"Cache of record schema"($) {
|
|
1986
|
+
$mol_assert_equal($mol_schema_record({ foo: $mol_schema_float }), $mol_schema_record({ foo: $mol_schema_float }));
|
|
1987
|
+
$mol_assert_unique($mol_schema_record({ foo: $mol_schema_float }), $mol_schema_record({ foo: $mol_schema_string }));
|
|
1988
|
+
},
|
|
1748
1989
|
"Record schema"($) {
|
|
1749
1990
|
const User = $mol_schema_record({
|
|
1750
1991
|
name: $mol_schema_string,
|
|
@@ -1795,7 +2036,7 @@ var $;
|
|
|
1795
2036
|
});
|
|
1796
2037
|
$mol_assert_equal(true, User.check({ name: 'foo', age: 123 }));
|
|
1797
2038
|
$mol_assert_equal(true, User.check({ name: null }));
|
|
1798
|
-
$mol_assert_equal({ name: 'foo', age:
|
|
2039
|
+
$mol_assert_equal({ name: 'foo', age: null }, User.cast({ name: 'foo', age: false }));
|
|
1799
2040
|
$mol_assert_equal({ name: 'foo', age: undefined }, User.guard({ name: 'foo', age: undefined }));
|
|
1800
2041
|
$mol_assert_fail(() => User.guard({ name: 'foo', age: 'bar' }), 'Wrong field');
|
|
1801
2042
|
},
|
|
@@ -1830,6 +2071,10 @@ var $;
|
|
|
1830
2071
|
var $$;
|
|
1831
2072
|
(function ($$) {
|
|
1832
2073
|
$mol_test({
|
|
2074
|
+
"Cache of instance schema"($) {
|
|
2075
|
+
$mol_assert_equal($mol_schema_instance(Uint8Array), $mol_schema_instance(Uint8Array));
|
|
2076
|
+
$mol_assert_unique($mol_schema_instance(Uint8Array), $mol_schema_instance(Int8Array));
|
|
2077
|
+
},
|
|
1833
2078
|
"Class instance schema"($) {
|
|
1834
2079
|
const Blob = $mol_schema_instance(Uint8Array);
|
|
1835
2080
|
$mol_assert_equal('$mol_schema_instance<Uint8Array>', Blob + '', $mol_key(Blob));
|
|
@@ -1837,7 +2082,7 @@ var $;
|
|
|
1837
2082
|
$mol_assert_equal(false, Blob.check(new Int8Array));
|
|
1838
2083
|
$mol_assert_equal(false, Blob.check(null));
|
|
1839
2084
|
$mol_assert_equal(new Uint8Array([0, 1]), Blob.cast(new Uint8Array([0, 1])));
|
|
1840
|
-
$
|
|
2085
|
+
$mol_assert_fail(() => Blob.cast(new Int8Array), 'Wrong class');
|
|
1841
2086
|
$mol_assert_equal(new Uint8Array, Blob.guard(new Uint8Array));
|
|
1842
2087
|
$mol_assert_fail(() => Blob.guard(new Int8Array), 'Wrong class');
|
|
1843
2088
|
},
|
|
@@ -1859,6 +2104,55 @@ var $;
|
|
|
1859
2104
|
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
1860
2105
|
})($ || ($ = {}));
|
|
1861
2106
|
|
|
2107
|
+
;
|
|
2108
|
+
"use strict";
|
|
2109
|
+
var $;
|
|
2110
|
+
(function ($_1) {
|
|
2111
|
+
var $$;
|
|
2112
|
+
(function ($$) {
|
|
2113
|
+
$mol_test({
|
|
2114
|
+
"Integers as recursive Sets"($) {
|
|
2115
|
+
class Schema extends $mol_schema_lazy(() => $mol_schema_list(Schema)) {
|
|
2116
|
+
}
|
|
2117
|
+
$mol_assert_equal(Schema.default, []);
|
|
2118
|
+
$mol_assert_equal(Schema.check([]), true);
|
|
2119
|
+
$mol_assert_equal(Schema.check(''), false);
|
|
2120
|
+
$mol_assert_equal(Schema.guard([]), []);
|
|
2121
|
+
$mol_assert_fail(() => Schema.guard(''), 'Non array');
|
|
2122
|
+
$mol_assert_equal(Schema.cast([]), []);
|
|
2123
|
+
$mol_assert_equal(Schema.cast(''), []);
|
|
2124
|
+
},
|
|
2125
|
+
});
|
|
2126
|
+
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
2127
|
+
})($ || ($ = {}));
|
|
2128
|
+
|
|
2129
|
+
;
|
|
2130
|
+
"use strict";
|
|
2131
|
+
var $;
|
|
2132
|
+
(function ($_1) {
|
|
2133
|
+
var $$;
|
|
2134
|
+
(function ($$) {
|
|
2135
|
+
$mol_test({
|
|
2136
|
+
"JSON schema"($) {
|
|
2137
|
+
$mol_assert_equal('$mol_schema_json', $mol_schema_json + '', $mol_key($mol_schema_json));
|
|
2138
|
+
$mol_assert_equal(true, $mol_schema_json.check(null));
|
|
2139
|
+
$mol_assert_equal(true, $mol_schema_json.check(0));
|
|
2140
|
+
$mol_assert_equal(true, $mol_schema_json.check(false));
|
|
2141
|
+
$mol_assert_equal(true, $mol_schema_json.check(''));
|
|
2142
|
+
$mol_assert_equal(true, $mol_schema_json.check([]));
|
|
2143
|
+
$mol_assert_equal(true, $mol_schema_json.check({}));
|
|
2144
|
+
$mol_assert_equal(false, $mol_schema_json.check(undefined));
|
|
2145
|
+
$mol_assert_equal(false, $mol_schema_json.check(new Date));
|
|
2146
|
+
$mol_assert_equal(false, $mol_schema_json.check({ __proto__: {} }));
|
|
2147
|
+
$mol_assert_equal({}, $mol_schema_json.cast(new Date));
|
|
2148
|
+
$mol_assert_equal({ foo: 777, bar: {} }, $mol_schema_json.cast({ foo: 777, bar: new Date }));
|
|
2149
|
+
$mol_assert_equal({ foo: [null, 0, false, ''] }, $mol_schema_json.guard({ foo: [null, 0, false, ''] }));
|
|
2150
|
+
$mol_assert_fail(() => $mol_schema_json.guard({ foo: [new Date] }), 'Wrong variant');
|
|
2151
|
+
},
|
|
2152
|
+
});
|
|
2153
|
+
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
2154
|
+
})($ || ($ = {}));
|
|
2155
|
+
|
|
1862
2156
|
;
|
|
1863
2157
|
"use strict";
|
|
1864
2158
|
var $;
|
|
@@ -1952,7 +2246,7 @@ var $;
|
|
|
1952
2246
|
} + '', class Some extends $mol_schema_maybe($mol_schema_float) {
|
|
1953
2247
|
} + '', class Some extends $mol_schema_every([$mol_schema_float]) {
|
|
1954
2248
|
} + '', class Some extends $mol_schema_list($mol_schema_float) {
|
|
1955
|
-
} + '', class Some extends $mol_schema_dict($mol_schema_string, $mol_schema_string) {
|
|
2249
|
+
} + '', class Some extends $mol_schema_dict([$mol_schema_string, $mol_schema_string]) {
|
|
1956
2250
|
} + '', class Some extends $mol_schema_record({ name: $mol_schema_string }) {
|
|
1957
2251
|
} + '', class Some extends $mol_schema_partial({ name: $mol_schema_string }) {
|
|
1958
2252
|
} + '');
|