mol_schema 0.0.21 → 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 +17 -15
- package/node.d.ts +406 -165
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +370 -73
- package/node.js.map +1 -1
- package/node.meta.tree +2 -0
- package/node.mjs +370 -73
- package/node.test.js +615 -255
- package/node.test.js.map +1 -1
- package/package.json +16 -5
- package/web.d.ts +406 -165
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +370 -73
- package/web.js.map +1 -1
- package/web.meta.tree +2 -0
- package/web.mjs +370 -73
- package/web.test.js +313 -18
- 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 $;
|
|
@@ -1366,6 +1356,72 @@ var $;
|
|
|
1366
1356
|
});
|
|
1367
1357
|
})($ || ($ = {}));
|
|
1368
1358
|
|
|
1359
|
+
;
|
|
1360
|
+
"use strict";
|
|
1361
|
+
var $;
|
|
1362
|
+
(function ($) {
|
|
1363
|
+
$mol_test({
|
|
1364
|
+
'get'() {
|
|
1365
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1366
|
+
$mol_assert_equal(proxy.foo, 777);
|
|
1367
|
+
},
|
|
1368
|
+
'has'() {
|
|
1369
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1370
|
+
$mol_assert_equal('foo' in proxy, true);
|
|
1371
|
+
},
|
|
1372
|
+
'set'() {
|
|
1373
|
+
const target = { foo: 777 };
|
|
1374
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1375
|
+
proxy.foo = 123;
|
|
1376
|
+
$mol_assert_equal(target.foo, 123);
|
|
1377
|
+
},
|
|
1378
|
+
'getOwnPropertyDescriptor'() {
|
|
1379
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777 }));
|
|
1380
|
+
$mol_assert_like(Object.getOwnPropertyDescriptor(proxy, 'foo'), {
|
|
1381
|
+
value: 777,
|
|
1382
|
+
writable: true,
|
|
1383
|
+
enumerable: true,
|
|
1384
|
+
configurable: true,
|
|
1385
|
+
});
|
|
1386
|
+
},
|
|
1387
|
+
'ownKeys'() {
|
|
1388
|
+
const proxy = $mol_delegate({}, () => ({ foo: 777, [Symbol.toStringTag]: 'bar' }));
|
|
1389
|
+
$mol_assert_like(Reflect.ownKeys(proxy), ['foo', Symbol.toStringTag]);
|
|
1390
|
+
},
|
|
1391
|
+
'getPrototypeOf'() {
|
|
1392
|
+
class Foo {
|
|
1393
|
+
}
|
|
1394
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1395
|
+
$mol_assert_equal(Object.getPrototypeOf(proxy), Foo.prototype);
|
|
1396
|
+
},
|
|
1397
|
+
'setPrototypeOf'() {
|
|
1398
|
+
class Foo {
|
|
1399
|
+
}
|
|
1400
|
+
const target = {};
|
|
1401
|
+
const proxy = $mol_delegate({}, () => target);
|
|
1402
|
+
Object.setPrototypeOf(proxy, Foo.prototype);
|
|
1403
|
+
$mol_assert_equal(Object.getPrototypeOf(target), Foo.prototype);
|
|
1404
|
+
},
|
|
1405
|
+
'instanceof'() {
|
|
1406
|
+
class Foo {
|
|
1407
|
+
}
|
|
1408
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1409
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1410
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1411
|
+
},
|
|
1412
|
+
'autobind'() {
|
|
1413
|
+
class Foo {
|
|
1414
|
+
}
|
|
1415
|
+
const proxy = $mol_delegate({}, () => new Foo);
|
|
1416
|
+
$mol_assert_ok(proxy instanceof Foo);
|
|
1417
|
+
$mol_assert_ok(proxy instanceof $mol_delegate);
|
|
1418
|
+
},
|
|
1419
|
+
});
|
|
1420
|
+
})($ || ($ = {}));
|
|
1421
|
+
|
|
1422
|
+
;
|
|
1423
|
+
"use strict";
|
|
1424
|
+
|
|
1369
1425
|
;
|
|
1370
1426
|
"use strict";
|
|
1371
1427
|
var $;
|
|
@@ -1380,6 +1436,149 @@ var $;
|
|
|
1380
1436
|
});
|
|
1381
1437
|
})($ || ($ = {}));
|
|
1382
1438
|
|
|
1439
|
+
;
|
|
1440
|
+
"use strict";
|
|
1441
|
+
var $;
|
|
1442
|
+
(function ($) {
|
|
1443
|
+
$mol_test({
|
|
1444
|
+
'run callback'() {
|
|
1445
|
+
class Plus1 extends $mol_wrapper {
|
|
1446
|
+
static wrap(task) {
|
|
1447
|
+
return function (...args) {
|
|
1448
|
+
return task.call(this, ...args) + 1;
|
|
1449
|
+
};
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
$mol_assert_equal(Plus1.run(() => 2), 3);
|
|
1453
|
+
},
|
|
1454
|
+
'wrap function'() {
|
|
1455
|
+
class Plus1 extends $mol_wrapper {
|
|
1456
|
+
static wrap(task) {
|
|
1457
|
+
return function (...args) {
|
|
1458
|
+
return task.call(this, ...args) + 1;
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
const obj = {
|
|
1463
|
+
level: 2,
|
|
1464
|
+
pow: Plus1.func(function (a) {
|
|
1465
|
+
return a ** this.level;
|
|
1466
|
+
})
|
|
1467
|
+
};
|
|
1468
|
+
$mol_assert_equal(obj.pow(2), 5);
|
|
1469
|
+
},
|
|
1470
|
+
'decorate field getter'() {
|
|
1471
|
+
class Plus1 extends $mol_wrapper {
|
|
1472
|
+
static last = 0;
|
|
1473
|
+
static wrap(task) {
|
|
1474
|
+
return function (...args) {
|
|
1475
|
+
return Plus1.last = (task.call(this, ...args) || 0) + 1;
|
|
1476
|
+
};
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
class Foo {
|
|
1480
|
+
static get two() {
|
|
1481
|
+
return 1;
|
|
1482
|
+
}
|
|
1483
|
+
static set two(next) { }
|
|
1484
|
+
}
|
|
1485
|
+
__decorate([
|
|
1486
|
+
Plus1.field
|
|
1487
|
+
], Foo, "two", null);
|
|
1488
|
+
$mol_assert_equal(Foo.two, 2);
|
|
1489
|
+
Foo.two = 3;
|
|
1490
|
+
$mol_assert_equal(Plus1.last, 2);
|
|
1491
|
+
$mol_assert_equal(Foo.two, 2);
|
|
1492
|
+
},
|
|
1493
|
+
'decorate instance method'() {
|
|
1494
|
+
class Plus1 extends $mol_wrapper {
|
|
1495
|
+
static wrap(task) {
|
|
1496
|
+
return function (...args) {
|
|
1497
|
+
return task.call(this, ...args) + 1;
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
class Foo1 {
|
|
1502
|
+
level = 2;
|
|
1503
|
+
pow(a) {
|
|
1504
|
+
return a ** this.level;
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
__decorate([
|
|
1508
|
+
Plus1.method
|
|
1509
|
+
], Foo1.prototype, "pow", null);
|
|
1510
|
+
const Foo2 = Foo1;
|
|
1511
|
+
const foo = new Foo2;
|
|
1512
|
+
$mol_assert_equal(foo.pow(2), 5);
|
|
1513
|
+
},
|
|
1514
|
+
'decorate static method'() {
|
|
1515
|
+
class Plus1 extends $mol_wrapper {
|
|
1516
|
+
static wrap(task) {
|
|
1517
|
+
return function (...args) {
|
|
1518
|
+
return task.call(this, ...args) + 1;
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
class Foo {
|
|
1523
|
+
static level = 2;
|
|
1524
|
+
static pow(a) {
|
|
1525
|
+
return a ** this.level;
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
__decorate([
|
|
1529
|
+
Plus1.method
|
|
1530
|
+
], Foo, "pow", null);
|
|
1531
|
+
$mol_assert_equal(Foo.pow(2), 5);
|
|
1532
|
+
},
|
|
1533
|
+
'decorate class'() {
|
|
1534
|
+
class BarInc extends $mol_wrapper {
|
|
1535
|
+
static wrap(task) {
|
|
1536
|
+
return function (...args) {
|
|
1537
|
+
const foo = task.call(this, ...args);
|
|
1538
|
+
foo.bar++;
|
|
1539
|
+
return foo;
|
|
1540
|
+
};
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
let Foo = class Foo {
|
|
1544
|
+
bar;
|
|
1545
|
+
constructor(bar) {
|
|
1546
|
+
this.bar = bar;
|
|
1547
|
+
}
|
|
1548
|
+
};
|
|
1549
|
+
Foo = __decorate([
|
|
1550
|
+
BarInc.class
|
|
1551
|
+
], Foo);
|
|
1552
|
+
$mol_assert_equal(new Foo(2).bar, 3);
|
|
1553
|
+
},
|
|
1554
|
+
});
|
|
1555
|
+
})($ || ($ = {}));
|
|
1556
|
+
|
|
1557
|
+
;
|
|
1558
|
+
"use strict";
|
|
1559
|
+
var $;
|
|
1560
|
+
(function ($) {
|
|
1561
|
+
$mol_test({
|
|
1562
|
+
'memoize field'() {
|
|
1563
|
+
class Foo {
|
|
1564
|
+
static one = 1;
|
|
1565
|
+
static get two() {
|
|
1566
|
+
return ++this.one;
|
|
1567
|
+
}
|
|
1568
|
+
static set two(next) { }
|
|
1569
|
+
}
|
|
1570
|
+
__decorate([
|
|
1571
|
+
$mol_memo.field
|
|
1572
|
+
], Foo, "two", null);
|
|
1573
|
+
$mol_assert_equal(Foo.two, 2);
|
|
1574
|
+
$mol_assert_equal(Foo.two, 2);
|
|
1575
|
+
Foo.two = 3;
|
|
1576
|
+
$mol_assert_equal(Foo.two, 3);
|
|
1577
|
+
$mol_assert_equal(Foo.two, 3);
|
|
1578
|
+
},
|
|
1579
|
+
});
|
|
1580
|
+
})($ || ($ = {}));
|
|
1581
|
+
|
|
1383
1582
|
;
|
|
1384
1583
|
"use strict";
|
|
1385
1584
|
/** @jsx $mol_jsx */
|
|
@@ -1455,6 +1654,10 @@ var $;
|
|
|
1455
1654
|
var $$;
|
|
1456
1655
|
(function ($$) {
|
|
1457
1656
|
$mol_test({
|
|
1657
|
+
"Cache of enum schema"($) {
|
|
1658
|
+
$mol_assert_equal($mol_schema_enum(['foo']), $mol_schema_enum(['foo']));
|
|
1659
|
+
$mol_assert_unique($mol_schema_enum(['foo']), $mol_schema_enum(['bar']));
|
|
1660
|
+
},
|
|
1458
1661
|
"Enum options"($) {
|
|
1459
1662
|
const Config = $mol_schema_enum([123, 'foo']);
|
|
1460
1663
|
$mol_assert_equal('$mol_schema_enum<[123,"foo"]>', Config + '', $mol_key(Config));
|
|
@@ -1463,9 +1666,9 @@ var $;
|
|
|
1463
1666
|
$mol_assert_equal(false, Config.check(true));
|
|
1464
1667
|
$mol_assert_equal(false, Config.check(321));
|
|
1465
1668
|
$mol_assert_equal(false, Config.check('bar'));
|
|
1466
|
-
$mol_assert_equal(
|
|
1467
|
-
$mol_assert_equal('foo',
|
|
1468
|
-
$mol_assert_equal(
|
|
1669
|
+
$mol_assert_equal(Config.cast(123), 123);
|
|
1670
|
+
$mol_assert_equal(Config.cast('foo'), 'foo');
|
|
1671
|
+
$mol_assert_equal(Config.cast('bar'), 123);
|
|
1469
1672
|
$mol_assert_equal(123, Config.guard(123));
|
|
1470
1673
|
$mol_assert_fail(() => Config.guard(321), 'No one option');
|
|
1471
1674
|
},
|
|
@@ -1522,6 +1725,10 @@ var $;
|
|
|
1522
1725
|
var $$;
|
|
1523
1726
|
(function ($$) {
|
|
1524
1727
|
$mol_test({
|
|
1728
|
+
"Cache of some schema"($) {
|
|
1729
|
+
$mol_assert_equal($mol_schema_some([$mol_schema_float]), $mol_schema_some([$mol_schema_float]));
|
|
1730
|
+
$mol_assert_unique($mol_schema_some([$mol_schema_float]), $mol_schema_some([$mol_schema_string]));
|
|
1731
|
+
},
|
|
1525
1732
|
"Some variant"($) {
|
|
1526
1733
|
const Config = $mol_schema_some([$mol_schema_float, $mol_schema_string]);
|
|
1527
1734
|
$mol_assert_equal('$mol_schema_some<[$mol_schema_float,$mol_schema_string]>', Config + '');
|
|
@@ -1545,6 +1752,10 @@ var $;
|
|
|
1545
1752
|
var $$;
|
|
1546
1753
|
(function ($$) {
|
|
1547
1754
|
$mol_test({
|
|
1755
|
+
"Cache of maybe schema"($) {
|
|
1756
|
+
$mol_assert_equal($mol_schema_maybe($mol_schema_float), $mol_schema_maybe($mol_schema_float));
|
|
1757
|
+
$mol_assert_unique($mol_schema_maybe($mol_schema_float), $mol_schema_maybe($mol_schema_string));
|
|
1758
|
+
},
|
|
1548
1759
|
"Optional value"($) {
|
|
1549
1760
|
const Config = $mol_schema_maybe($mol_schema_string);
|
|
1550
1761
|
$mol_assert_equal('$mol_schema_maybe<$mol_schema_string>', Config + '');
|
|
@@ -1600,8 +1811,12 @@ var $;
|
|
|
1600
1811
|
var $$;
|
|
1601
1812
|
(function ($$) {
|
|
1602
1813
|
$mol_test({
|
|
1814
|
+
"Cache of range schema"($) {
|
|
1815
|
+
$mol_assert_equal($mol_schema_range([0, 1]), $mol_schema_range([0, 1]));
|
|
1816
|
+
$mol_assert_unique($mol_schema_range([0, 1]), $mol_schema_range([0, 2]));
|
|
1817
|
+
},
|
|
1603
1818
|
"Float range schema"($) {
|
|
1604
|
-
const Range = $mol_schema_range(4, 8);
|
|
1819
|
+
const Range = $mol_schema_range([4, 8]);
|
|
1605
1820
|
$mol_assert_equal(true, Range.check(5.5));
|
|
1606
1821
|
$mol_assert_equal(true, Range.check(4));
|
|
1607
1822
|
$mol_assert_equal(true, Range.check(8));
|
|
@@ -1626,9 +1841,13 @@ var $;
|
|
|
1626
1841
|
var $$;
|
|
1627
1842
|
(function ($$) {
|
|
1628
1843
|
$mol_test({
|
|
1844
|
+
"Cache of every schema"($) {
|
|
1845
|
+
$mol_assert_equal($mol_schema_every([$mol_schema_float]), $mol_schema_every([$mol_schema_float]));
|
|
1846
|
+
$mol_assert_unique($mol_schema_every([$mol_schema_float]), $mol_schema_every([$mol_schema_string]));
|
|
1847
|
+
},
|
|
1629
1848
|
"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 + '');
|
|
1849
|
+
const Narrow = $mol_schema_every([$mol_schema_integer, $mol_schema_range([1, 8]), $mol_schema_range([4, 10])]);
|
|
1850
|
+
$mol_assert_equal('$mol_schema_every<[$mol_schema_integer,$mol_schema_range<[1,8]>,$mol_schema_range<[4,10]>]>', Narrow + '');
|
|
1632
1851
|
$mol_assert_equal(true, Narrow.check(6));
|
|
1633
1852
|
$mol_assert_equal(true, Narrow.check(4));
|
|
1634
1853
|
$mol_assert_equal(true, Narrow.check(8));
|
|
@@ -1654,6 +1873,10 @@ var $;
|
|
|
1654
1873
|
var $$;
|
|
1655
1874
|
(function ($$) {
|
|
1656
1875
|
$mol_test({
|
|
1876
|
+
"Cache of list schema"($) {
|
|
1877
|
+
$mol_assert_equal($mol_schema_list($mol_schema_float), $mol_schema_list($mol_schema_float));
|
|
1878
|
+
$mol_assert_unique($mol_schema_list($mol_schema_float), $mol_schema_list($mol_schema_string));
|
|
1879
|
+
},
|
|
1657
1880
|
"Array schema"($) {
|
|
1658
1881
|
const Vector = $mol_schema_list($mol_schema_float);
|
|
1659
1882
|
$mol_assert_equal('$mol_schema_list<$mol_schema_float>', Vector + '');
|
|
@@ -1678,6 +1901,10 @@ var $;
|
|
|
1678
1901
|
var $$;
|
|
1679
1902
|
(function ($$) {
|
|
1680
1903
|
$mol_test({
|
|
1904
|
+
"Cache of pattern schema"($) {
|
|
1905
|
+
$mol_assert_equal($mol_schema_pattern(/foo/), $mol_schema_pattern(/foo/));
|
|
1906
|
+
$mol_assert_unique($mol_schema_pattern(/foo/), $mol_schema_pattern(/bar/));
|
|
1907
|
+
},
|
|
1681
1908
|
"String pattern schema"($) {
|
|
1682
1909
|
const Email = $mol_schema_pattern(/^.*@.*$/);
|
|
1683
1910
|
$mol_assert_equal('$mol_schema_pattern</^.*@.*$/>', Email + '', $mol_key(Email));
|
|
@@ -1721,8 +1948,12 @@ var $;
|
|
|
1721
1948
|
var $;
|
|
1722
1949
|
(function ($_1) {
|
|
1723
1950
|
$mol_test({
|
|
1951
|
+
"Cache of dict schema"($) {
|
|
1952
|
+
$mol_assert_equal($mol_schema_dict([$mol_schema_string, $mol_schema_float]), $mol_schema_dict([$mol_schema_string, $mol_schema_float]));
|
|
1953
|
+
$mol_assert_unique($mol_schema_dict([$mol_schema_string, $mol_schema_float]), $mol_schema_dict([$mol_schema_string, $mol_schema_string]));
|
|
1954
|
+
},
|
|
1724
1955
|
"Dictionary schema"($) {
|
|
1725
|
-
const Flags = $mol_schema_dict($mol_schema_pattern(/^[a-z]+$/), $mol_schema_boolean);
|
|
1956
|
+
const Flags = $mol_schema_dict([$mol_schema_pattern(/^[a-z]+$/), $mol_schema_boolean]);
|
|
1726
1957
|
$mol_assert_equal(true, Flags.check({}));
|
|
1727
1958
|
$mol_assert_equal(true, Flags.check({ foo: false }));
|
|
1728
1959
|
$mol_assert_equal(false, Flags.check({ f00: false }));
|
|
@@ -1745,6 +1976,10 @@ var $;
|
|
|
1745
1976
|
var $$;
|
|
1746
1977
|
(function ($$) {
|
|
1747
1978
|
$mol_test({
|
|
1979
|
+
"Cache of record schema"($) {
|
|
1980
|
+
$mol_assert_equal($mol_schema_record({ foo: $mol_schema_float }), $mol_schema_record({ foo: $mol_schema_float }));
|
|
1981
|
+
$mol_assert_unique($mol_schema_record({ foo: $mol_schema_float }), $mol_schema_record({ foo: $mol_schema_string }));
|
|
1982
|
+
},
|
|
1748
1983
|
"Record schema"($) {
|
|
1749
1984
|
const User = $mol_schema_record({
|
|
1750
1985
|
name: $mol_schema_string,
|
|
@@ -1803,6 +2038,66 @@ var $;
|
|
|
1803
2038
|
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
1804
2039
|
})($ || ($ = {}));
|
|
1805
2040
|
|
|
2041
|
+
;
|
|
2042
|
+
"use strict";
|
|
2043
|
+
var $;
|
|
2044
|
+
(function ($_1) {
|
|
2045
|
+
var $$;
|
|
2046
|
+
(function ($$) {
|
|
2047
|
+
$mol_test({
|
|
2048
|
+
"BigInt schema"($) {
|
|
2049
|
+
$mol_assert_equal('$mol_schema_bigint', $mol_schema_bigint + '', $mol_key($mol_schema_bigint));
|
|
2050
|
+
$mol_assert_equal(true, $mol_schema_bigint.check(0n));
|
|
2051
|
+
$mol_assert_equal(false, $mol_schema_bigint.check(0));
|
|
2052
|
+
$mol_assert_equal(1n, $mol_schema_bigint.cast(1n));
|
|
2053
|
+
$mol_assert_equal(1n, $mol_schema_bigint.cast(1));
|
|
2054
|
+
$mol_assert_equal(0n, $mol_schema_bigint.guard(0n));
|
|
2055
|
+
$mol_assert_fail(() => $mol_schema_bigint.guard(1), 'Wrong type');
|
|
2056
|
+
},
|
|
2057
|
+
});
|
|
2058
|
+
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
2059
|
+
})($ || ($ = {}));
|
|
2060
|
+
|
|
2061
|
+
;
|
|
2062
|
+
"use strict";
|
|
2063
|
+
var $;
|
|
2064
|
+
(function ($_1) {
|
|
2065
|
+
var $$;
|
|
2066
|
+
(function ($$) {
|
|
2067
|
+
$mol_test({
|
|
2068
|
+
"Cache of instance schema"($) {
|
|
2069
|
+
$mol_assert_equal($mol_schema_instance(Uint8Array), $mol_schema_instance(Uint8Array));
|
|
2070
|
+
$mol_assert_unique($mol_schema_instance(Uint8Array), $mol_schema_instance(Int8Array));
|
|
2071
|
+
},
|
|
2072
|
+
"Class instance schema"($) {
|
|
2073
|
+
const Blob = $mol_schema_instance(Uint8Array);
|
|
2074
|
+
$mol_assert_equal('$mol_schema_instance<Uint8Array>', Blob + '', $mol_key(Blob));
|
|
2075
|
+
$mol_assert_equal(true, Blob.check(new Uint8Array));
|
|
2076
|
+
$mol_assert_equal(false, Blob.check(new Int8Array));
|
|
2077
|
+
$mol_assert_equal(false, Blob.check(null));
|
|
2078
|
+
$mol_assert_equal(new Uint8Array([0, 1]), Blob.cast(new Uint8Array([0, 1])));
|
|
2079
|
+
$mol_assert_equal(new Uint8Array, Blob.cast(new Int8Array([1, -1])));
|
|
2080
|
+
$mol_assert_equal(new Uint8Array, Blob.guard(new Uint8Array));
|
|
2081
|
+
$mol_assert_fail(() => Blob.guard(new Int8Array), 'Wrong class');
|
|
2082
|
+
},
|
|
2083
|
+
"Boxed instance schema"($) {
|
|
2084
|
+
const Str = $mol_schema_instance(String);
|
|
2085
|
+
$mol_assert_equal('$mol_schema_instance<String>', Str + '', $mol_key(Str));
|
|
2086
|
+
$mol_assert_equal(true, Str.check(Object('')));
|
|
2087
|
+
$mol_assert_equal(true, Str.check(''));
|
|
2088
|
+
$mol_assert_equal(true, Object('') instanceof Str);
|
|
2089
|
+
},
|
|
2090
|
+
"Schema instance schema"($) {
|
|
2091
|
+
const Str = $mol_schema_instance($mol_schema_instance(String));
|
|
2092
|
+
$mol_assert_equal('$mol_schema_instance<String>', Str + '', $mol_key(Str));
|
|
2093
|
+
$mol_assert_equal(true, Str.check(Object('')));
|
|
2094
|
+
$mol_assert_equal(true, Str.check(''));
|
|
2095
|
+
$mol_assert_equal(true, Object('') instanceof Str);
|
|
2096
|
+
},
|
|
2097
|
+
});
|
|
2098
|
+
})($$ = $_1.$$ || ($_1.$$ = {}));
|
|
2099
|
+
})($ || ($ = {}));
|
|
2100
|
+
|
|
1806
2101
|
;
|
|
1807
2102
|
"use strict";
|
|
1808
2103
|
var $;
|
|
@@ -1896,7 +2191,7 @@ var $;
|
|
|
1896
2191
|
} + '', class Some extends $mol_schema_maybe($mol_schema_float) {
|
|
1897
2192
|
} + '', class Some extends $mol_schema_every([$mol_schema_float]) {
|
|
1898
2193
|
} + '', class Some extends $mol_schema_list($mol_schema_float) {
|
|
1899
|
-
} + '', class Some extends $mol_schema_dict($mol_schema_string, $mol_schema_string) {
|
|
2194
|
+
} + '', class Some extends $mol_schema_dict([$mol_schema_string, $mol_schema_string]) {
|
|
1900
2195
|
} + '', class Some extends $mol_schema_record({ name: $mol_schema_string }) {
|
|
1901
2196
|
} + '', class Some extends $mol_schema_partial({ name: $mol_schema_string }) {
|
|
1902
2197
|
} + '');
|