mol_db 0.0.795 → 0.0.796
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 +296 -2
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +296 -2
- package/web.test.js.map +1 -1
package/node.test.js
CHANGED
|
@@ -1437,6 +1437,298 @@ var $;
|
|
|
1437
1437
|
;
|
|
1438
1438
|
"use strict";
|
|
1439
1439
|
var $;
|
|
1440
|
+
(function ($) {
|
|
1441
|
+
function $mol_guid(length = 8, exists = () => false) {
|
|
1442
|
+
for (;;) {
|
|
1443
|
+
let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
|
|
1444
|
+
if (exists(id))
|
|
1445
|
+
continue;
|
|
1446
|
+
return id;
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
$.$mol_guid = $mol_guid;
|
|
1450
|
+
})($ || ($ = {}));
|
|
1451
|
+
//mol/guid/guid.ts
|
|
1452
|
+
;
|
|
1453
|
+
"use strict";
|
|
1454
|
+
var $;
|
|
1455
|
+
(function ($) {
|
|
1456
|
+
function $mol_range2(item = index => index, size = () => Number.POSITIVE_INFINITY) {
|
|
1457
|
+
return new Proxy(new $mol_range2_array(), {
|
|
1458
|
+
get(target, field) {
|
|
1459
|
+
if (typeof field === 'string') {
|
|
1460
|
+
if (field === 'length')
|
|
1461
|
+
return size();
|
|
1462
|
+
const index = Number(field);
|
|
1463
|
+
if (index < 0)
|
|
1464
|
+
return undefined;
|
|
1465
|
+
if (index >= size())
|
|
1466
|
+
return undefined;
|
|
1467
|
+
if (index === Math.trunc(index))
|
|
1468
|
+
return item(index);
|
|
1469
|
+
}
|
|
1470
|
+
return target[field];
|
|
1471
|
+
},
|
|
1472
|
+
set(target, field) {
|
|
1473
|
+
return $mol_fail(new TypeError(`Lazy range is read only (trying to set field ${JSON.stringify(field)})`));
|
|
1474
|
+
},
|
|
1475
|
+
ownKeys(target) {
|
|
1476
|
+
return [...Array(size())].map((v, i) => String(i)).concat('length');
|
|
1477
|
+
},
|
|
1478
|
+
getOwnPropertyDescriptor(target, field) {
|
|
1479
|
+
if (field === "length")
|
|
1480
|
+
return {
|
|
1481
|
+
value: size(),
|
|
1482
|
+
writable: true,
|
|
1483
|
+
enumerable: false,
|
|
1484
|
+
configurable: false,
|
|
1485
|
+
};
|
|
1486
|
+
const index = Number(field);
|
|
1487
|
+
if (index === Math.trunc(index))
|
|
1488
|
+
return {
|
|
1489
|
+
get: () => this.get(target, field, this),
|
|
1490
|
+
enumerable: true,
|
|
1491
|
+
configurable: true,
|
|
1492
|
+
};
|
|
1493
|
+
return Object.getOwnPropertyDescriptor(target, field);
|
|
1494
|
+
}
|
|
1495
|
+
});
|
|
1496
|
+
}
|
|
1497
|
+
$.$mol_range2 = $mol_range2;
|
|
1498
|
+
class $mol_range2_array extends Array {
|
|
1499
|
+
concat(...tail) {
|
|
1500
|
+
if (tail.length === 0)
|
|
1501
|
+
return this;
|
|
1502
|
+
if (tail.length > 1) {
|
|
1503
|
+
let list = this;
|
|
1504
|
+
for (let item of tail)
|
|
1505
|
+
list = list.concat(item);
|
|
1506
|
+
return list;
|
|
1507
|
+
}
|
|
1508
|
+
return $mol_range2(index => index < this.length ? this[index] : tail[0][index - this.length], () => this.length + tail[0].length);
|
|
1509
|
+
}
|
|
1510
|
+
filter(check, context) {
|
|
1511
|
+
const filtered = new $mol_range2_array();
|
|
1512
|
+
for (let index = 0; index < this.length; ++index) {
|
|
1513
|
+
const item = this[index];
|
|
1514
|
+
if (check.call(context, item, index, this))
|
|
1515
|
+
filtered.push(item);
|
|
1516
|
+
}
|
|
1517
|
+
return filtered;
|
|
1518
|
+
}
|
|
1519
|
+
forEach(proceed, context) {
|
|
1520
|
+
for (let [key, value] of this.entries())
|
|
1521
|
+
proceed.call(context, value, key, this);
|
|
1522
|
+
}
|
|
1523
|
+
map(proceed, context) {
|
|
1524
|
+
return $mol_range2(index => proceed.call(context, this[index], index, this), () => this.length);
|
|
1525
|
+
}
|
|
1526
|
+
reduce(merge, result) {
|
|
1527
|
+
let index = 0;
|
|
1528
|
+
if (arguments.length === 1) {
|
|
1529
|
+
result = this[index++];
|
|
1530
|
+
}
|
|
1531
|
+
for (; index < this.length; ++index) {
|
|
1532
|
+
result = merge(result, this[index], index, this);
|
|
1533
|
+
}
|
|
1534
|
+
return result;
|
|
1535
|
+
}
|
|
1536
|
+
toReversed() {
|
|
1537
|
+
return $mol_range2(index => this[this.length - 1 - index], () => this.length);
|
|
1538
|
+
}
|
|
1539
|
+
slice(from = 0, to = this.length) {
|
|
1540
|
+
return $mol_range2(index => this[from + index], () => Math.min(to, this.length) - from);
|
|
1541
|
+
}
|
|
1542
|
+
some(check, context) {
|
|
1543
|
+
for (let index = 0; index < this.length; ++index) {
|
|
1544
|
+
if (check.call(context, this[index], index, this))
|
|
1545
|
+
return true;
|
|
1546
|
+
}
|
|
1547
|
+
return false;
|
|
1548
|
+
}
|
|
1549
|
+
every(check, context) {
|
|
1550
|
+
for (let index = 0; index < this.length; ++index) {
|
|
1551
|
+
if (!check.call(context, this[index], index, this))
|
|
1552
|
+
return false;
|
|
1553
|
+
}
|
|
1554
|
+
return true;
|
|
1555
|
+
}
|
|
1556
|
+
reverse() {
|
|
1557
|
+
return $mol_fail(new TypeError(`Mutable reverse is forbidden. Use toReversed instead.`));
|
|
1558
|
+
}
|
|
1559
|
+
sort() {
|
|
1560
|
+
return $mol_fail(new TypeError(`Mutable sort is forbidden. Use toSorted instead.`));
|
|
1561
|
+
}
|
|
1562
|
+
[Symbol.toPrimitive]() {
|
|
1563
|
+
return $mol_guid();
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
$.$mol_range2_array = $mol_range2_array;
|
|
1567
|
+
})($ || ($ = {}));
|
|
1568
|
+
//mol/range2/range2.ts
|
|
1569
|
+
;
|
|
1570
|
+
"use strict";
|
|
1571
|
+
var $;
|
|
1572
|
+
(function ($) {
|
|
1573
|
+
$mol_test({
|
|
1574
|
+
'lazy calls'() {
|
|
1575
|
+
let calls = 0;
|
|
1576
|
+
const list = $mol_range2(index => (++calls, index), () => 10);
|
|
1577
|
+
$mol_assert_ok(list instanceof Array);
|
|
1578
|
+
$mol_assert_equal(list.length, 10);
|
|
1579
|
+
$mol_assert_equal(list[-1], undefined);
|
|
1580
|
+
$mol_assert_equal(list[0], 0);
|
|
1581
|
+
$mol_assert_equal(list[9], 9);
|
|
1582
|
+
$mol_assert_equal(list[9.5], undefined);
|
|
1583
|
+
$mol_assert_equal(list[10], undefined);
|
|
1584
|
+
$mol_assert_equal(calls, 2);
|
|
1585
|
+
},
|
|
1586
|
+
'infinity list'() {
|
|
1587
|
+
let calls = 0;
|
|
1588
|
+
const list = $mol_range2(index => (++calls, index));
|
|
1589
|
+
$mol_assert_equal(list.length, Number.POSITIVE_INFINITY);
|
|
1590
|
+
$mol_assert_equal(list[0], 0);
|
|
1591
|
+
$mol_assert_equal(list[4], 4);
|
|
1592
|
+
$mol_assert_equal(list[Number.MAX_SAFE_INTEGER], Number.MAX_SAFE_INTEGER);
|
|
1593
|
+
$mol_assert_equal(list[Number.POSITIVE_INFINITY], undefined);
|
|
1594
|
+
$mol_assert_equal(calls, 3);
|
|
1595
|
+
},
|
|
1596
|
+
'stringify'() {
|
|
1597
|
+
const list = $mol_range2(i => i, () => 5);
|
|
1598
|
+
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
|
1599
|
+
$mol_assert_equal(list.join(';'), '0;1;2;3;4');
|
|
1600
|
+
},
|
|
1601
|
+
'for-of'() {
|
|
1602
|
+
let log = '';
|
|
1603
|
+
for (let i of $mol_range2(i => i + 1, () => 5)) {
|
|
1604
|
+
log += i;
|
|
1605
|
+
}
|
|
1606
|
+
$mol_assert_equal(log, '12345');
|
|
1607
|
+
},
|
|
1608
|
+
'for-in'() {
|
|
1609
|
+
let log = '';
|
|
1610
|
+
for (let i in $mol_range2(i => i, () => 5)) {
|
|
1611
|
+
log += i;
|
|
1612
|
+
}
|
|
1613
|
+
$mol_assert_equal(log, '01234');
|
|
1614
|
+
},
|
|
1615
|
+
'forEach'() {
|
|
1616
|
+
let log = '';
|
|
1617
|
+
$mol_range2(i => i, () => 5).forEach(i => log += i);
|
|
1618
|
+
$mol_assert_equal(log, '01234');
|
|
1619
|
+
},
|
|
1620
|
+
'lazy concat'() {
|
|
1621
|
+
let calls1 = 0;
|
|
1622
|
+
let calls2 = 0;
|
|
1623
|
+
const list = $mol_range2(index => (++calls1, index), () => 5).concat([0, 1, 2, 3, 4], $mol_range2(index => (++calls2, index), () => 5));
|
|
1624
|
+
$mol_assert_ok(list instanceof Array);
|
|
1625
|
+
$mol_assert_equal(list.length, 15);
|
|
1626
|
+
$mol_assert_equal(list[0], 0);
|
|
1627
|
+
$mol_assert_equal(list[4], 4);
|
|
1628
|
+
$mol_assert_equal(list[5], 0);
|
|
1629
|
+
$mol_assert_equal(list[9], 4);
|
|
1630
|
+
$mol_assert_equal(list[10], 0);
|
|
1631
|
+
$mol_assert_equal(list[14], 4);
|
|
1632
|
+
$mol_assert_equal(list[15], undefined);
|
|
1633
|
+
$mol_assert_equal(calls1, 2);
|
|
1634
|
+
$mol_assert_equal(calls2, 2);
|
|
1635
|
+
},
|
|
1636
|
+
'filter'() {
|
|
1637
|
+
let calls = 0;
|
|
1638
|
+
const list = $mol_range2(index => (++calls, index), () => 10).filter(v => v % 2).slice(0, 3);
|
|
1639
|
+
$mol_assert_ok(list instanceof Array);
|
|
1640
|
+
$mol_assert_equal(list.length, 3);
|
|
1641
|
+
$mol_assert_equal(list[0], 1);
|
|
1642
|
+
$mol_assert_equal(list[2], 5);
|
|
1643
|
+
$mol_assert_equal(list[3], undefined);
|
|
1644
|
+
$mol_assert_equal(calls, 10);
|
|
1645
|
+
},
|
|
1646
|
+
'reverse'() {
|
|
1647
|
+
let calls = 0;
|
|
1648
|
+
const list = $mol_range2(index => (++calls, index), () => 10).toReversed().slice(0, 3);
|
|
1649
|
+
$mol_assert_ok(list instanceof Array);
|
|
1650
|
+
$mol_assert_equal(list.length, 3);
|
|
1651
|
+
$mol_assert_equal(list[0], 9);
|
|
1652
|
+
$mol_assert_equal(list[2], 7);
|
|
1653
|
+
$mol_assert_equal(list[3], undefined);
|
|
1654
|
+
$mol_assert_equal(calls, 2);
|
|
1655
|
+
},
|
|
1656
|
+
'reduce'() {
|
|
1657
|
+
let calls = 0;
|
|
1658
|
+
const list = $mol_range2().slice(1, 6);
|
|
1659
|
+
$mol_assert_equal(list.reduce((s, v) => s + v), 15);
|
|
1660
|
+
$mol_assert_equal(list.reduce((s, v) => s + v, 5), 20);
|
|
1661
|
+
},
|
|
1662
|
+
'lazy map'() {
|
|
1663
|
+
let calls1 = 0;
|
|
1664
|
+
let calls2 = 0;
|
|
1665
|
+
const source = $mol_range2(index => (++calls1, index), () => 5);
|
|
1666
|
+
const target = source.map((item, index, self) => {
|
|
1667
|
+
++calls2;
|
|
1668
|
+
$mol_assert_equal(source, self);
|
|
1669
|
+
return index + 10;
|
|
1670
|
+
}, () => 5);
|
|
1671
|
+
$mol_assert_ok(target instanceof Array);
|
|
1672
|
+
$mol_assert_equal(target.length, 5);
|
|
1673
|
+
$mol_assert_equal(target[0], 10);
|
|
1674
|
+
$mol_assert_equal(target[4], 14);
|
|
1675
|
+
$mol_assert_equal(target[5], undefined);
|
|
1676
|
+
$mol_assert_equal(calls1, 2);
|
|
1677
|
+
$mol_assert_equal(calls2, 2);
|
|
1678
|
+
},
|
|
1679
|
+
'lazy slice'() {
|
|
1680
|
+
let calls = 0;
|
|
1681
|
+
const list = $mol_range2(index => (++calls, index), () => 10).slice(3, 7);
|
|
1682
|
+
$mol_assert_ok(list instanceof Array);
|
|
1683
|
+
$mol_assert_equal(list.length, 4);
|
|
1684
|
+
$mol_assert_equal(list[0], 3);
|
|
1685
|
+
$mol_assert_equal(list[3], 6);
|
|
1686
|
+
$mol_assert_equal(list[4], undefined);
|
|
1687
|
+
$mol_assert_equal(calls, 2);
|
|
1688
|
+
},
|
|
1689
|
+
'lazy some'() {
|
|
1690
|
+
let calls = 0;
|
|
1691
|
+
$mol_assert_ok($mol_range2(index => (++calls, index), () => 5).some(v => v >= 2));
|
|
1692
|
+
$mol_assert_equal(calls, 3);
|
|
1693
|
+
$mol_assert_not($mol_range2(i => i, () => 0).some(v => true));
|
|
1694
|
+
$mol_assert_ok($mol_range2(i => i).some(v => v > 5));
|
|
1695
|
+
},
|
|
1696
|
+
'lazy every'() {
|
|
1697
|
+
let calls = 0;
|
|
1698
|
+
$mol_assert_not($mol_range2(index => (++calls, index), () => 5).every(v => v < 2));
|
|
1699
|
+
$mol_assert_equal(calls, 3);
|
|
1700
|
+
$mol_assert_ok($mol_range2(i => i, () => 0).every(v => false));
|
|
1701
|
+
$mol_assert_not($mol_range2(i => i).every(v => v < 5));
|
|
1702
|
+
},
|
|
1703
|
+
'lazyfy'() {
|
|
1704
|
+
let calls = 0;
|
|
1705
|
+
const list = new $mol_range2_array(...[0, 1, 2, 3, 4, 5]).map(i => (++calls, i + 10)).slice(2);
|
|
1706
|
+
$mol_assert_ok(list instanceof Array);
|
|
1707
|
+
$mol_assert_equal(list.length, 4);
|
|
1708
|
+
$mol_assert_equal(calls, 0);
|
|
1709
|
+
$mol_assert_equal(list[0], 12);
|
|
1710
|
+
$mol_assert_equal(list[3], 15);
|
|
1711
|
+
$mol_assert_equal(list[4], undefined);
|
|
1712
|
+
$mol_assert_equal(calls, 2);
|
|
1713
|
+
},
|
|
1714
|
+
'prevent modification'() {
|
|
1715
|
+
const list = $mol_range2(i => i, () => 5);
|
|
1716
|
+
$mol_assert_fail(() => list.push(4), TypeError);
|
|
1717
|
+
$mol_assert_fail(() => list.pop(), TypeError);
|
|
1718
|
+
$mol_assert_fail(() => list.unshift(4), TypeError);
|
|
1719
|
+
$mol_assert_fail(() => list.shift(), TypeError);
|
|
1720
|
+
$mol_assert_fail(() => list.splice(1, 2), TypeError);
|
|
1721
|
+
$mol_assert_fail(() => list[1] = 2, TypeError);
|
|
1722
|
+
$mol_assert_fail(() => list.reverse(), TypeError);
|
|
1723
|
+
$mol_assert_fail(() => list.sort(), TypeError);
|
|
1724
|
+
$mol_assert_equal(list.toString(), '0,1,2,3,4');
|
|
1725
|
+
}
|
|
1726
|
+
});
|
|
1727
|
+
})($ || ($ = {}));
|
|
1728
|
+
//mol/range2/range2.test.ts
|
|
1729
|
+
;
|
|
1730
|
+
"use strict";
|
|
1731
|
+
var $;
|
|
1440
1732
|
(function ($) {
|
|
1441
1733
|
$.$mol_compare_deep_cache = new WeakMap();
|
|
1442
1734
|
function $mol_compare_deep(left, right) {
|
|
@@ -1482,6 +1774,8 @@ var $;
|
|
|
1482
1774
|
result = compare_pojo(left, right);
|
|
1483
1775
|
else if (!Reflect.getPrototypeOf(left_proto))
|
|
1484
1776
|
result = compare_pojo(left, right);
|
|
1777
|
+
else if (Symbol.toPrimitive in left)
|
|
1778
|
+
result = compare_primitive(left, right);
|
|
1485
1779
|
else if (Array.isArray(left))
|
|
1486
1780
|
result = compare_array(left, right);
|
|
1487
1781
|
else if (left instanceof Set)
|
|
@@ -1492,8 +1786,6 @@ var $;
|
|
|
1492
1786
|
result = compare_buffer(left, right);
|
|
1493
1787
|
else if (Symbol.iterator in left)
|
|
1494
1788
|
result = compare_iterator(left[Symbol.iterator](), right[Symbol.iterator]());
|
|
1495
|
-
else if (Symbol.toPrimitive in left)
|
|
1496
|
-
result = compare_primitive(left, right);
|
|
1497
1789
|
else
|
|
1498
1790
|
result = false;
|
|
1499
1791
|
}
|
|
@@ -1603,6 +1895,8 @@ var $;
|
|
|
1603
1895
|
$mol_assert_ok($mol_compare_deep([1, [2]], [1, [2]]));
|
|
1604
1896
|
$mol_assert_not($mol_compare_deep([1, 2], [1, 3]));
|
|
1605
1897
|
$mol_assert_not($mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
1898
|
+
$mol_assert_not($mol_compare_deep($mol_range2().slice(0, 0), new Array()));
|
|
1899
|
+
$mol_assert_not($mol_compare_deep($mol_range2(), $mol_range2()));
|
|
1606
1900
|
},
|
|
1607
1901
|
'Non POJO are different'() {
|
|
1608
1902
|
class Thing extends Object {
|