@leofcoin/chain 1.6.1 → 1.6.3
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/exports/browser/{browser-Ei0BXMlu-C0woTcHa.js → browser-Ei0BXMlu-9eQR3AGp.js} +2 -2
- package/exports/browser/chain.js +678 -661
- package/exports/browser/{client-A009z8av-Ssch8Yea.js → client-A009z8av-DavUUkay.js} +4 -4
- package/exports/browser/{_polyfill-node.child_process-CblghArn.js → index-Bz6K16zr.js} +6 -2003
- package/exports/browser/{index-G74WLzL7-BnLRqHoy.js → index-G74WLzL7-d1Vs_wqe.js} +2 -2
- package/exports/browser/{index-YQrIDBUQ-APwDgUUG.js → index-YQrIDBUQ-CbL47K_x.js} +2 -2
- package/exports/browser/{messages-lWRTai7t-DJnHZSdM.js → messages-lWRTai7t-Cs3eU5Cb.js} +2 -2
- package/exports/browser/{node-browser-CeM_F-HL.js → node-browser-CC3grAN3.js} +4 -4
- package/exports/browser/node-browser.js +2 -2
- package/exports/browser/workers/block-worker.js +1 -1
- package/exports/browser/workers/machine-worker.js +348 -349
- package/exports/browser/workers/{worker-CbAak_hM.js → worker-CFrwP8cD.js} +1 -4
- package/exports/chain.js +2 -2
- package/exports/workers/block-worker.js +1 -1
- package/exports/workers/machine-worker.js +348 -349
- package/exports/workers/{worker-CbAak_hM.js → worker-CFrwP8cD.js} +1 -4
- package/package.json +27 -56
- package/exports/browser/_polyfill-node.url-BLK_MhDf.js +0 -1196
package/exports/browser/chain.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as BigNumber, L as Logger, v as version$1, h as hexZeroPad, i as isBigNumberish, a as arrayify, b as isBytes, T as TransactionMessage, t as toBase58, C as ContractMessage, R as RawTransactionMessage, g as getDefaultExportFromCjs, c as BlockMessage, d as BWMessage, e as BWRequestMessage } from './index-Bz6K16zr.js';
|
|
2
2
|
|
|
3
3
|
if (!globalThis.DEBUG) {
|
|
4
4
|
let DEBUG = [];
|
|
@@ -1432,764 +1432,781 @@ function requireIterator () {
|
|
|
1432
1432
|
return iterator;
|
|
1433
1433
|
}
|
|
1434
1434
|
|
|
1435
|
-
var yallist
|
|
1435
|
+
var yallist;
|
|
1436
|
+
var hasRequiredYallist;
|
|
1436
1437
|
|
|
1437
|
-
|
|
1438
|
-
|
|
1438
|
+
function requireYallist () {
|
|
1439
|
+
if (hasRequiredYallist) return yallist;
|
|
1440
|
+
hasRequiredYallist = 1;
|
|
1441
|
+
yallist = Yallist;
|
|
1439
1442
|
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
if (!(self instanceof Yallist$1)) {
|
|
1443
|
-
self = new Yallist$1();
|
|
1444
|
-
}
|
|
1443
|
+
Yallist.Node = Node;
|
|
1444
|
+
Yallist.create = Yallist;
|
|
1445
1445
|
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1446
|
+
function Yallist (list) {
|
|
1447
|
+
var self = this;
|
|
1448
|
+
if (!(self instanceof Yallist)) {
|
|
1449
|
+
self = new Yallist();
|
|
1450
|
+
}
|
|
1449
1451
|
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
});
|
|
1454
|
-
} else if (arguments.length > 0) {
|
|
1455
|
-
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
1456
|
-
self.push(arguments[i]);
|
|
1457
|
-
}
|
|
1458
|
-
}
|
|
1452
|
+
self.tail = null;
|
|
1453
|
+
self.head = null;
|
|
1454
|
+
self.length = 0;
|
|
1459
1455
|
|
|
1460
|
-
|
|
1461
|
-
|
|
1456
|
+
if (list && typeof list.forEach === 'function') {
|
|
1457
|
+
list.forEach(function (item) {
|
|
1458
|
+
self.push(item);
|
|
1459
|
+
});
|
|
1460
|
+
} else if (arguments.length > 0) {
|
|
1461
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
1462
|
+
self.push(arguments[i]);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1462
1465
|
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
throw new Error('removing node which does not belong to this list')
|
|
1466
|
-
}
|
|
1466
|
+
return self
|
|
1467
|
+
}
|
|
1467
1468
|
|
|
1468
|
-
|
|
1469
|
-
|
|
1469
|
+
Yallist.prototype.removeNode = function (node) {
|
|
1470
|
+
if (node.list !== this) {
|
|
1471
|
+
throw new Error('removing node which does not belong to this list')
|
|
1472
|
+
}
|
|
1470
1473
|
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
}
|
|
1474
|
+
var next = node.next;
|
|
1475
|
+
var prev = node.prev;
|
|
1474
1476
|
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1477
|
+
if (next) {
|
|
1478
|
+
next.prev = prev;
|
|
1479
|
+
}
|
|
1478
1480
|
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
if (node === this.tail) {
|
|
1483
|
-
this.tail = prev;
|
|
1484
|
-
}
|
|
1481
|
+
if (prev) {
|
|
1482
|
+
prev.next = next;
|
|
1483
|
+
}
|
|
1485
1484
|
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1485
|
+
if (node === this.head) {
|
|
1486
|
+
this.head = next;
|
|
1487
|
+
}
|
|
1488
|
+
if (node === this.tail) {
|
|
1489
|
+
this.tail = prev;
|
|
1490
|
+
}
|
|
1490
1491
|
|
|
1491
|
-
|
|
1492
|
-
|
|
1492
|
+
node.list.length--;
|
|
1493
|
+
node.next = null;
|
|
1494
|
+
node.prev = null;
|
|
1495
|
+
node.list = null;
|
|
1493
1496
|
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
return
|
|
1497
|
-
}
|
|
1497
|
+
return next
|
|
1498
|
+
};
|
|
1498
1499
|
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1500
|
+
Yallist.prototype.unshiftNode = function (node) {
|
|
1501
|
+
if (node === this.head) {
|
|
1502
|
+
return
|
|
1503
|
+
}
|
|
1502
1504
|
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
if (head) {
|
|
1507
|
-
head.prev = node;
|
|
1508
|
-
}
|
|
1505
|
+
if (node.list) {
|
|
1506
|
+
node.list.removeNode(node);
|
|
1507
|
+
}
|
|
1509
1508
|
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
}
|
|
1509
|
+
var head = this.head;
|
|
1510
|
+
node.list = this;
|
|
1511
|
+
node.next = head;
|
|
1512
|
+
if (head) {
|
|
1513
|
+
head.prev = node;
|
|
1514
|
+
}
|
|
1516
1515
|
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1516
|
+
this.head = node;
|
|
1517
|
+
if (!this.tail) {
|
|
1518
|
+
this.tail = node;
|
|
1519
|
+
}
|
|
1520
|
+
this.length++;
|
|
1521
|
+
};
|
|
1521
1522
|
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1523
|
+
Yallist.prototype.pushNode = function (node) {
|
|
1524
|
+
if (node === this.tail) {
|
|
1525
|
+
return
|
|
1526
|
+
}
|
|
1525
1527
|
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
if (tail) {
|
|
1530
|
-
tail.next = node;
|
|
1531
|
-
}
|
|
1528
|
+
if (node.list) {
|
|
1529
|
+
node.list.removeNode(node);
|
|
1530
|
+
}
|
|
1532
1531
|
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
}
|
|
1532
|
+
var tail = this.tail;
|
|
1533
|
+
node.list = this;
|
|
1534
|
+
node.prev = tail;
|
|
1535
|
+
if (tail) {
|
|
1536
|
+
tail.next = node;
|
|
1537
|
+
}
|
|
1539
1538
|
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
};
|
|
1539
|
+
this.tail = node;
|
|
1540
|
+
if (!this.head) {
|
|
1541
|
+
this.head = node;
|
|
1542
|
+
}
|
|
1543
|
+
this.length++;
|
|
1544
|
+
};
|
|
1546
1545
|
|
|
1547
|
-
Yallist
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
};
|
|
1546
|
+
Yallist.prototype.push = function () {
|
|
1547
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
1548
|
+
push(this, arguments[i]);
|
|
1549
|
+
}
|
|
1550
|
+
return this.length
|
|
1551
|
+
};
|
|
1553
1552
|
|
|
1554
|
-
Yallist
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1553
|
+
Yallist.prototype.unshift = function () {
|
|
1554
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
|
1555
|
+
unshift(this, arguments[i]);
|
|
1556
|
+
}
|
|
1557
|
+
return this.length
|
|
1558
|
+
};
|
|
1558
1559
|
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
} else {
|
|
1564
|
-
this.head = null;
|
|
1565
|
-
}
|
|
1566
|
-
this.length--;
|
|
1567
|
-
return res
|
|
1568
|
-
};
|
|
1560
|
+
Yallist.prototype.pop = function () {
|
|
1561
|
+
if (!this.tail) {
|
|
1562
|
+
return undefined
|
|
1563
|
+
}
|
|
1569
1564
|
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1565
|
+
var res = this.tail.value;
|
|
1566
|
+
this.tail = this.tail.prev;
|
|
1567
|
+
if (this.tail) {
|
|
1568
|
+
this.tail.next = null;
|
|
1569
|
+
} else {
|
|
1570
|
+
this.head = null;
|
|
1571
|
+
}
|
|
1572
|
+
this.length--;
|
|
1573
|
+
return res
|
|
1574
|
+
};
|
|
1574
1575
|
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
} else {
|
|
1580
|
-
this.tail = null;
|
|
1581
|
-
}
|
|
1582
|
-
this.length--;
|
|
1583
|
-
return res
|
|
1584
|
-
};
|
|
1576
|
+
Yallist.prototype.shift = function () {
|
|
1577
|
+
if (!this.head) {
|
|
1578
|
+
return undefined
|
|
1579
|
+
}
|
|
1585
1580
|
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
}
|
|
1581
|
+
var res = this.head.value;
|
|
1582
|
+
this.head = this.head.next;
|
|
1583
|
+
if (this.head) {
|
|
1584
|
+
this.head.prev = null;
|
|
1585
|
+
} else {
|
|
1586
|
+
this.tail = null;
|
|
1587
|
+
}
|
|
1588
|
+
this.length--;
|
|
1589
|
+
return res
|
|
1590
|
+
};
|
|
1593
1591
|
|
|
1594
|
-
Yallist
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
};
|
|
1592
|
+
Yallist.prototype.forEach = function (fn, thisp) {
|
|
1593
|
+
thisp = thisp || this;
|
|
1594
|
+
for (var walker = this.head, i = 0; walker !== null; i++) {
|
|
1595
|
+
fn.call(thisp, walker.value, i, this);
|
|
1596
|
+
walker = walker.next;
|
|
1597
|
+
}
|
|
1598
|
+
};
|
|
1601
1599
|
|
|
1602
|
-
Yallist
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
}
|
|
1610
|
-
};
|
|
1600
|
+
Yallist.prototype.forEachReverse = function (fn, thisp) {
|
|
1601
|
+
thisp = thisp || this;
|
|
1602
|
+
for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
|
|
1603
|
+
fn.call(thisp, walker.value, i, this);
|
|
1604
|
+
walker = walker.prev;
|
|
1605
|
+
}
|
|
1606
|
+
};
|
|
1611
1607
|
|
|
1612
|
-
Yallist
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
};
|
|
1608
|
+
Yallist.prototype.get = function (n) {
|
|
1609
|
+
for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
|
|
1610
|
+
// abort out of the list early if we hit a cycle
|
|
1611
|
+
walker = walker.next;
|
|
1612
|
+
}
|
|
1613
|
+
if (i === n && walker !== null) {
|
|
1614
|
+
return walker.value
|
|
1615
|
+
}
|
|
1616
|
+
};
|
|
1621
1617
|
|
|
1622
|
-
Yallist
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
};
|
|
1618
|
+
Yallist.prototype.getReverse = function (n) {
|
|
1619
|
+
for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
|
|
1620
|
+
// abort out of the list early if we hit a cycle
|
|
1621
|
+
walker = walker.prev;
|
|
1622
|
+
}
|
|
1623
|
+
if (i === n && walker !== null) {
|
|
1624
|
+
return walker.value
|
|
1625
|
+
}
|
|
1626
|
+
};
|
|
1631
1627
|
|
|
1632
|
-
Yallist
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
};
|
|
1628
|
+
Yallist.prototype.map = function (fn, thisp) {
|
|
1629
|
+
thisp = thisp || this;
|
|
1630
|
+
var res = new Yallist();
|
|
1631
|
+
for (var walker = this.head; walker !== null;) {
|
|
1632
|
+
res.push(fn.call(thisp, walker.value, this));
|
|
1633
|
+
walker = walker.next;
|
|
1634
|
+
}
|
|
1635
|
+
return res
|
|
1636
|
+
};
|
|
1641
1637
|
|
|
1642
|
-
Yallist
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
throw new TypeError('Reduce of empty list with no initial value')
|
|
1652
|
-
}
|
|
1638
|
+
Yallist.prototype.mapReverse = function (fn, thisp) {
|
|
1639
|
+
thisp = thisp || this;
|
|
1640
|
+
var res = new Yallist();
|
|
1641
|
+
for (var walker = this.tail; walker !== null;) {
|
|
1642
|
+
res.push(fn.call(thisp, walker.value, this));
|
|
1643
|
+
walker = walker.prev;
|
|
1644
|
+
}
|
|
1645
|
+
return res
|
|
1646
|
+
};
|
|
1653
1647
|
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1648
|
+
Yallist.prototype.reduce = function (fn, initial) {
|
|
1649
|
+
var acc;
|
|
1650
|
+
var walker = this.head;
|
|
1651
|
+
if (arguments.length > 1) {
|
|
1652
|
+
acc = initial;
|
|
1653
|
+
} else if (this.head) {
|
|
1654
|
+
walker = this.head.next;
|
|
1655
|
+
acc = this.head.value;
|
|
1656
|
+
} else {
|
|
1657
|
+
throw new TypeError('Reduce of empty list with no initial value')
|
|
1658
|
+
}
|
|
1658
1659
|
|
|
1659
|
-
|
|
1660
|
-
|
|
1660
|
+
for (var i = 0; walker !== null; i++) {
|
|
1661
|
+
acc = fn(acc, walker.value, i);
|
|
1662
|
+
walker = walker.next;
|
|
1663
|
+
}
|
|
1661
1664
|
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
var walker = this.tail;
|
|
1665
|
-
if (arguments.length > 1) {
|
|
1666
|
-
acc = initial;
|
|
1667
|
-
} else if (this.tail) {
|
|
1668
|
-
walker = this.tail.prev;
|
|
1669
|
-
acc = this.tail.value;
|
|
1670
|
-
} else {
|
|
1671
|
-
throw new TypeError('Reduce of empty list with no initial value')
|
|
1672
|
-
}
|
|
1665
|
+
return acc
|
|
1666
|
+
};
|
|
1673
1667
|
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1668
|
+
Yallist.prototype.reduceReverse = function (fn, initial) {
|
|
1669
|
+
var acc;
|
|
1670
|
+
var walker = this.tail;
|
|
1671
|
+
if (arguments.length > 1) {
|
|
1672
|
+
acc = initial;
|
|
1673
|
+
} else if (this.tail) {
|
|
1674
|
+
walker = this.tail.prev;
|
|
1675
|
+
acc = this.tail.value;
|
|
1676
|
+
} else {
|
|
1677
|
+
throw new TypeError('Reduce of empty list with no initial value')
|
|
1678
|
+
}
|
|
1678
1679
|
|
|
1679
|
-
|
|
1680
|
-
|
|
1680
|
+
for (var i = this.length - 1; walker !== null; i--) {
|
|
1681
|
+
acc = fn(acc, walker.value, i);
|
|
1682
|
+
walker = walker.prev;
|
|
1683
|
+
}
|
|
1681
1684
|
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
for (var i = 0, walker = this.head; walker !== null; i++) {
|
|
1685
|
-
arr[i] = walker.value;
|
|
1686
|
-
walker = walker.next;
|
|
1687
|
-
}
|
|
1688
|
-
return arr
|
|
1689
|
-
};
|
|
1685
|
+
return acc
|
|
1686
|
+
};
|
|
1690
1687
|
|
|
1691
|
-
Yallist
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
};
|
|
1688
|
+
Yallist.prototype.toArray = function () {
|
|
1689
|
+
var arr = new Array(this.length);
|
|
1690
|
+
for (var i = 0, walker = this.head; walker !== null; i++) {
|
|
1691
|
+
arr[i] = walker.value;
|
|
1692
|
+
walker = walker.next;
|
|
1693
|
+
}
|
|
1694
|
+
return arr
|
|
1695
|
+
};
|
|
1699
1696
|
|
|
1700
|
-
Yallist
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
}
|
|
1709
|
-
var ret = new Yallist$1();
|
|
1710
|
-
if (to < from || to < 0) {
|
|
1711
|
-
return ret
|
|
1712
|
-
}
|
|
1713
|
-
if (from < 0) {
|
|
1714
|
-
from = 0;
|
|
1715
|
-
}
|
|
1716
|
-
if (to > this.length) {
|
|
1717
|
-
to = this.length;
|
|
1718
|
-
}
|
|
1719
|
-
for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
|
|
1720
|
-
walker = walker.next;
|
|
1721
|
-
}
|
|
1722
|
-
for (; walker !== null && i < to; i++, walker = walker.next) {
|
|
1723
|
-
ret.push(walker.value);
|
|
1724
|
-
}
|
|
1725
|
-
return ret
|
|
1726
|
-
};
|
|
1697
|
+
Yallist.prototype.toArrayReverse = function () {
|
|
1698
|
+
var arr = new Array(this.length);
|
|
1699
|
+
for (var i = 0, walker = this.tail; walker !== null; i++) {
|
|
1700
|
+
arr[i] = walker.value;
|
|
1701
|
+
walker = walker.prev;
|
|
1702
|
+
}
|
|
1703
|
+
return arr
|
|
1704
|
+
};
|
|
1727
1705
|
|
|
1728
|
-
Yallist
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
};
|
|
1706
|
+
Yallist.prototype.slice = function (from, to) {
|
|
1707
|
+
to = to || this.length;
|
|
1708
|
+
if (to < 0) {
|
|
1709
|
+
to += this.length;
|
|
1710
|
+
}
|
|
1711
|
+
from = from || 0;
|
|
1712
|
+
if (from < 0) {
|
|
1713
|
+
from += this.length;
|
|
1714
|
+
}
|
|
1715
|
+
var ret = new Yallist();
|
|
1716
|
+
if (to < from || to < 0) {
|
|
1717
|
+
return ret
|
|
1718
|
+
}
|
|
1719
|
+
if (from < 0) {
|
|
1720
|
+
from = 0;
|
|
1721
|
+
}
|
|
1722
|
+
if (to > this.length) {
|
|
1723
|
+
to = this.length;
|
|
1724
|
+
}
|
|
1725
|
+
for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
|
|
1726
|
+
walker = walker.next;
|
|
1727
|
+
}
|
|
1728
|
+
for (; walker !== null && i < to; i++, walker = walker.next) {
|
|
1729
|
+
ret.push(walker.value);
|
|
1730
|
+
}
|
|
1731
|
+
return ret
|
|
1732
|
+
};
|
|
1755
1733
|
|
|
1756
|
-
Yallist
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1734
|
+
Yallist.prototype.sliceReverse = function (from, to) {
|
|
1735
|
+
to = to || this.length;
|
|
1736
|
+
if (to < 0) {
|
|
1737
|
+
to += this.length;
|
|
1738
|
+
}
|
|
1739
|
+
from = from || 0;
|
|
1740
|
+
if (from < 0) {
|
|
1741
|
+
from += this.length;
|
|
1742
|
+
}
|
|
1743
|
+
var ret = new Yallist();
|
|
1744
|
+
if (to < from || to < 0) {
|
|
1745
|
+
return ret
|
|
1746
|
+
}
|
|
1747
|
+
if (from < 0) {
|
|
1748
|
+
from = 0;
|
|
1749
|
+
}
|
|
1750
|
+
if (to > this.length) {
|
|
1751
|
+
to = this.length;
|
|
1752
|
+
}
|
|
1753
|
+
for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
|
|
1754
|
+
walker = walker.prev;
|
|
1755
|
+
}
|
|
1756
|
+
for (; walker !== null && i > from; i--, walker = walker.prev) {
|
|
1757
|
+
ret.push(walker.value);
|
|
1758
|
+
}
|
|
1759
|
+
return ret
|
|
1760
|
+
};
|
|
1763
1761
|
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1762
|
+
Yallist.prototype.splice = function (start, deleteCount, ...nodes) {
|
|
1763
|
+
if (start > this.length) {
|
|
1764
|
+
start = this.length - 1;
|
|
1765
|
+
}
|
|
1766
|
+
if (start < 0) {
|
|
1767
|
+
start = this.length + start;
|
|
1768
|
+
}
|
|
1767
1769
|
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
walker = this.removeNode(walker);
|
|
1772
|
-
}
|
|
1773
|
-
if (walker === null) {
|
|
1774
|
-
walker = this.tail;
|
|
1775
|
-
}
|
|
1770
|
+
for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
|
|
1771
|
+
walker = walker.next;
|
|
1772
|
+
}
|
|
1776
1773
|
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1774
|
+
var ret = [];
|
|
1775
|
+
for (var i = 0; walker && i < deleteCount; i++) {
|
|
1776
|
+
ret.push(walker.value);
|
|
1777
|
+
walker = this.removeNode(walker);
|
|
1778
|
+
}
|
|
1779
|
+
if (walker === null) {
|
|
1780
|
+
walker = this.tail;
|
|
1781
|
+
}
|
|
1780
1782
|
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
return ret;
|
|
1785
|
-
};
|
|
1783
|
+
if (walker !== this.head && walker !== this.tail) {
|
|
1784
|
+
walker = walker.prev;
|
|
1785
|
+
}
|
|
1786
1786
|
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
walker.prev = walker.next;
|
|
1793
|
-
walker.next = p;
|
|
1794
|
-
}
|
|
1795
|
-
this.head = tail;
|
|
1796
|
-
this.tail = head;
|
|
1797
|
-
return this
|
|
1798
|
-
};
|
|
1787
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
1788
|
+
walker = insert(this, walker, nodes[i]);
|
|
1789
|
+
}
|
|
1790
|
+
return ret;
|
|
1791
|
+
};
|
|
1799
1792
|
|
|
1800
|
-
function
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1793
|
+
Yallist.prototype.reverse = function () {
|
|
1794
|
+
var head = this.head;
|
|
1795
|
+
var tail = this.tail;
|
|
1796
|
+
for (var walker = head; walker !== null; walker = walker.prev) {
|
|
1797
|
+
var p = walker.prev;
|
|
1798
|
+
walker.prev = walker.next;
|
|
1799
|
+
walker.next = p;
|
|
1800
|
+
}
|
|
1801
|
+
this.head = tail;
|
|
1802
|
+
this.tail = head;
|
|
1803
|
+
return this
|
|
1804
|
+
};
|
|
1804
1805
|
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
self.head = inserted;
|
|
1810
|
-
}
|
|
1806
|
+
function insert (self, node, value) {
|
|
1807
|
+
var inserted = node === self.head ?
|
|
1808
|
+
new Node(value, null, node, self) :
|
|
1809
|
+
new Node(value, node, node.next, self);
|
|
1811
1810
|
|
|
1812
|
-
|
|
1811
|
+
if (inserted.next === null) {
|
|
1812
|
+
self.tail = inserted;
|
|
1813
|
+
}
|
|
1814
|
+
if (inserted.prev === null) {
|
|
1815
|
+
self.head = inserted;
|
|
1816
|
+
}
|
|
1813
1817
|
|
|
1814
|
-
|
|
1815
|
-
}
|
|
1818
|
+
self.length++;
|
|
1816
1819
|
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
if (!self.head) {
|
|
1820
|
-
self.head = self.tail;
|
|
1821
|
-
}
|
|
1822
|
-
self.length++;
|
|
1823
|
-
}
|
|
1820
|
+
return inserted
|
|
1821
|
+
}
|
|
1824
1822
|
|
|
1825
|
-
function
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
}
|
|
1823
|
+
function push (self, item) {
|
|
1824
|
+
self.tail = new Node(item, self.tail, null, self);
|
|
1825
|
+
if (!self.head) {
|
|
1826
|
+
self.head = self.tail;
|
|
1827
|
+
}
|
|
1828
|
+
self.length++;
|
|
1829
|
+
}
|
|
1832
1830
|
|
|
1833
|
-
function
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1831
|
+
function unshift (self, item) {
|
|
1832
|
+
self.head = new Node(item, null, self.head, self);
|
|
1833
|
+
if (!self.tail) {
|
|
1834
|
+
self.tail = self.head;
|
|
1835
|
+
}
|
|
1836
|
+
self.length++;
|
|
1837
|
+
}
|
|
1837
1838
|
|
|
1838
|
-
|
|
1839
|
-
|
|
1839
|
+
function Node (value, prev, next, list) {
|
|
1840
|
+
if (!(this instanceof Node)) {
|
|
1841
|
+
return new Node(value, prev, next, list)
|
|
1842
|
+
}
|
|
1840
1843
|
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
this.prev = prev;
|
|
1844
|
-
} else {
|
|
1845
|
-
this.prev = null;
|
|
1846
|
-
}
|
|
1844
|
+
this.list = list;
|
|
1845
|
+
this.value = value;
|
|
1847
1846
|
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1847
|
+
if (prev) {
|
|
1848
|
+
prev.next = this;
|
|
1849
|
+
this.prev = prev;
|
|
1850
|
+
} else {
|
|
1851
|
+
this.prev = null;
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
if (next) {
|
|
1855
|
+
next.prev = this;
|
|
1856
|
+
this.next = next;
|
|
1857
|
+
} else {
|
|
1858
|
+
this.next = null;
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
try {
|
|
1863
|
+
// add if support for Symbol.iterator is present
|
|
1864
|
+
requireIterator()(Yallist);
|
|
1865
|
+
} catch (er) {}
|
|
1866
|
+
return yallist;
|
|
1854
1867
|
}
|
|
1855
1868
|
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
const
|
|
1865
|
-
|
|
1866
|
-
const
|
|
1867
|
-
const
|
|
1868
|
-
const
|
|
1869
|
-
const
|
|
1870
|
-
const
|
|
1871
|
-
const
|
|
1872
|
-
const
|
|
1873
|
-
const
|
|
1874
|
-
|
|
1875
|
-
const
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
//
|
|
1880
|
-
//
|
|
1881
|
-
//
|
|
1882
|
-
//
|
|
1883
|
-
//
|
|
1884
|
-
//
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1869
|
+
var lruCache;
|
|
1870
|
+
var hasRequiredLruCache;
|
|
1871
|
+
|
|
1872
|
+
function requireLruCache () {
|
|
1873
|
+
if (hasRequiredLruCache) return lruCache;
|
|
1874
|
+
hasRequiredLruCache = 1;
|
|
1875
|
+
|
|
1876
|
+
// A linked list to keep track of recently-used-ness
|
|
1877
|
+
const Yallist = requireYallist();
|
|
1878
|
+
|
|
1879
|
+
const MAX = Symbol('max');
|
|
1880
|
+
const LENGTH = Symbol('length');
|
|
1881
|
+
const LENGTH_CALCULATOR = Symbol('lengthCalculator');
|
|
1882
|
+
const ALLOW_STALE = Symbol('allowStale');
|
|
1883
|
+
const MAX_AGE = Symbol('maxAge');
|
|
1884
|
+
const DISPOSE = Symbol('dispose');
|
|
1885
|
+
const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet');
|
|
1886
|
+
const LRU_LIST = Symbol('lruList');
|
|
1887
|
+
const CACHE = Symbol('cache');
|
|
1888
|
+
const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
|
|
1889
|
+
|
|
1890
|
+
const naiveLength = () => 1;
|
|
1891
|
+
|
|
1892
|
+
// lruList is a yallist where the head is the youngest
|
|
1893
|
+
// item, and the tail is the oldest. the list contains the Hit
|
|
1894
|
+
// objects as the entries.
|
|
1895
|
+
// Each Hit object has a reference to its Yallist.Node. This
|
|
1896
|
+
// never changes.
|
|
1897
|
+
//
|
|
1898
|
+
// cache is a Map (or PseudoMap) that matches the keys to
|
|
1899
|
+
// the Yallist.Node object.
|
|
1900
|
+
class LRUCache {
|
|
1901
|
+
constructor (options) {
|
|
1902
|
+
if (typeof options === 'number')
|
|
1903
|
+
options = { max: options };
|
|
1904
|
+
|
|
1905
|
+
if (!options)
|
|
1906
|
+
options = {};
|
|
1907
|
+
|
|
1908
|
+
if (options.max && (typeof options.max !== 'number' || options.max < 0))
|
|
1909
|
+
throw new TypeError('max must be a non-negative number')
|
|
1910
|
+
// Kind of weird to have a default max of Infinity, but oh well.
|
|
1911
|
+
this[MAX] = options.max || Infinity;
|
|
1912
|
+
|
|
1913
|
+
const lc = options.length || naiveLength;
|
|
1914
|
+
this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc;
|
|
1915
|
+
this[ALLOW_STALE] = options.stale || false;
|
|
1916
|
+
if (options.maxAge && typeof options.maxAge !== 'number')
|
|
1917
|
+
throw new TypeError('maxAge must be a number')
|
|
1918
|
+
this[MAX_AGE] = options.maxAge || 0;
|
|
1919
|
+
this[DISPOSE] = options.dispose;
|
|
1920
|
+
this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
|
|
1921
|
+
this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false;
|
|
1922
|
+
this.reset();
|
|
1923
|
+
}
|
|
1909
1924
|
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1925
|
+
// resize the cache when the max changes.
|
|
1926
|
+
set max (mL) {
|
|
1927
|
+
if (typeof mL !== 'number' || mL < 0)
|
|
1928
|
+
throw new TypeError('max must be a non-negative number')
|
|
1914
1929
|
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1930
|
+
this[MAX] = mL || Infinity;
|
|
1931
|
+
trim(this);
|
|
1932
|
+
}
|
|
1933
|
+
get max () {
|
|
1934
|
+
return this[MAX]
|
|
1935
|
+
}
|
|
1921
1936
|
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1937
|
+
set allowStale (allowStale) {
|
|
1938
|
+
this[ALLOW_STALE] = !!allowStale;
|
|
1939
|
+
}
|
|
1940
|
+
get allowStale () {
|
|
1941
|
+
return this[ALLOW_STALE]
|
|
1942
|
+
}
|
|
1928
1943
|
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1944
|
+
set maxAge (mA) {
|
|
1945
|
+
if (typeof mA !== 'number')
|
|
1946
|
+
throw new TypeError('maxAge must be a non-negative number')
|
|
1932
1947
|
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1948
|
+
this[MAX_AGE] = mA;
|
|
1949
|
+
trim(this);
|
|
1950
|
+
}
|
|
1951
|
+
get maxAge () {
|
|
1952
|
+
return this[MAX_AGE]
|
|
1953
|
+
}
|
|
1939
1954
|
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1955
|
+
// resize the cache when the lengthCalculator changes.
|
|
1956
|
+
set lengthCalculator (lC) {
|
|
1957
|
+
if (typeof lC !== 'function')
|
|
1958
|
+
lC = naiveLength;
|
|
1959
|
+
|
|
1960
|
+
if (lC !== this[LENGTH_CALCULATOR]) {
|
|
1961
|
+
this[LENGTH_CALCULATOR] = lC;
|
|
1962
|
+
this[LENGTH] = 0;
|
|
1963
|
+
this[LRU_LIST].forEach(hit => {
|
|
1964
|
+
hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
|
|
1965
|
+
this[LENGTH] += hit.length;
|
|
1966
|
+
});
|
|
1967
|
+
}
|
|
1968
|
+
trim(this);
|
|
1969
|
+
}
|
|
1970
|
+
get lengthCalculator () { return this[LENGTH_CALCULATOR] }
|
|
1956
1971
|
|
|
1957
|
-
|
|
1958
|
-
|
|
1972
|
+
get length () { return this[LENGTH] }
|
|
1973
|
+
get itemCount () { return this[LRU_LIST].length }
|
|
1959
1974
|
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1975
|
+
rforEach (fn, thisp) {
|
|
1976
|
+
thisp = thisp || this;
|
|
1977
|
+
for (let walker = this[LRU_LIST].tail; walker !== null;) {
|
|
1978
|
+
const prev = walker.prev;
|
|
1979
|
+
forEachStep(this, fn, walker, thisp);
|
|
1980
|
+
walker = prev;
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1968
1983
|
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1984
|
+
forEach (fn, thisp) {
|
|
1985
|
+
thisp = thisp || this;
|
|
1986
|
+
for (let walker = this[LRU_LIST].head; walker !== null;) {
|
|
1987
|
+
const next = walker.next;
|
|
1988
|
+
forEachStep(this, fn, walker, thisp);
|
|
1989
|
+
walker = next;
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1977
1992
|
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1993
|
+
keys () {
|
|
1994
|
+
return this[LRU_LIST].toArray().map(k => k.key)
|
|
1995
|
+
}
|
|
1981
1996
|
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1997
|
+
values () {
|
|
1998
|
+
return this[LRU_LIST].toArray().map(k => k.value)
|
|
1999
|
+
}
|
|
1985
2000
|
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
2001
|
+
reset () {
|
|
2002
|
+
if (this[DISPOSE] &&
|
|
2003
|
+
this[LRU_LIST] &&
|
|
2004
|
+
this[LRU_LIST].length) {
|
|
2005
|
+
this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value));
|
|
2006
|
+
}
|
|
1992
2007
|
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
2008
|
+
this[CACHE] = new Map(); // hash of items by key
|
|
2009
|
+
this[LRU_LIST] = new Yallist(); // list of items in order of use recency
|
|
2010
|
+
this[LENGTH] = 0; // length of items in the list
|
|
2011
|
+
}
|
|
1997
2012
|
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2013
|
+
dump () {
|
|
2014
|
+
return this[LRU_LIST].map(hit =>
|
|
2015
|
+
isStale(this, hit) ? false : {
|
|
2016
|
+
k: hit.key,
|
|
2017
|
+
v: hit.value,
|
|
2018
|
+
e: hit.now + (hit.maxAge || 0)
|
|
2019
|
+
}).toArray().filter(h => h)
|
|
2020
|
+
}
|
|
2006
2021
|
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2022
|
+
dumpLru () {
|
|
2023
|
+
return this[LRU_LIST]
|
|
2024
|
+
}
|
|
2010
2025
|
|
|
2011
|
-
|
|
2012
|
-
|
|
2026
|
+
set (key, value, maxAge) {
|
|
2027
|
+
maxAge = maxAge || this[MAX_AGE];
|
|
2013
2028
|
|
|
2014
|
-
|
|
2015
|
-
|
|
2029
|
+
if (maxAge && typeof maxAge !== 'number')
|
|
2030
|
+
throw new TypeError('maxAge must be a number')
|
|
2016
2031
|
|
|
2017
|
-
|
|
2018
|
-
|
|
2032
|
+
const now = maxAge ? Date.now() : 0;
|
|
2033
|
+
const len = this[LENGTH_CALCULATOR](value, key);
|
|
2019
2034
|
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2035
|
+
if (this[CACHE].has(key)) {
|
|
2036
|
+
if (len > this[MAX]) {
|
|
2037
|
+
del(this, this[CACHE].get(key));
|
|
2038
|
+
return false
|
|
2039
|
+
}
|
|
2025
2040
|
|
|
2026
|
-
|
|
2027
|
-
|
|
2041
|
+
const node = this[CACHE].get(key);
|
|
2042
|
+
const item = node.value;
|
|
2028
2043
|
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2044
|
+
// dispose of the old one before overwriting
|
|
2045
|
+
// split out into 2 ifs for better coverage tracking
|
|
2046
|
+
if (this[DISPOSE]) {
|
|
2047
|
+
if (!this[NO_DISPOSE_ON_SET])
|
|
2048
|
+
this[DISPOSE](key, item.value);
|
|
2049
|
+
}
|
|
2035
2050
|
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2051
|
+
item.now = now;
|
|
2052
|
+
item.maxAge = maxAge;
|
|
2053
|
+
item.value = value;
|
|
2054
|
+
this[LENGTH] += len - item.length;
|
|
2055
|
+
item.length = len;
|
|
2056
|
+
this.get(key);
|
|
2057
|
+
trim(this);
|
|
2058
|
+
return true
|
|
2059
|
+
}
|
|
2045
2060
|
|
|
2046
|
-
|
|
2061
|
+
const hit = new Entry(key, value, len, now, maxAge);
|
|
2047
2062
|
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2063
|
+
// oversized objects fall out of cache automatically.
|
|
2064
|
+
if (hit.length > this[MAX]) {
|
|
2065
|
+
if (this[DISPOSE])
|
|
2066
|
+
this[DISPOSE](key, value);
|
|
2052
2067
|
|
|
2053
|
-
|
|
2054
|
-
|
|
2068
|
+
return false
|
|
2069
|
+
}
|
|
2055
2070
|
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2071
|
+
this[LENGTH] += hit.length;
|
|
2072
|
+
this[LRU_LIST].unshift(hit);
|
|
2073
|
+
this[CACHE].set(key, this[LRU_LIST].head);
|
|
2074
|
+
trim(this);
|
|
2075
|
+
return true
|
|
2076
|
+
}
|
|
2062
2077
|
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2078
|
+
has (key) {
|
|
2079
|
+
if (!this[CACHE].has(key)) return false
|
|
2080
|
+
const hit = this[CACHE].get(key).value;
|
|
2081
|
+
return !isStale(this, hit)
|
|
2082
|
+
}
|
|
2068
2083
|
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2084
|
+
get (key) {
|
|
2085
|
+
return get(this, key, true)
|
|
2086
|
+
}
|
|
2072
2087
|
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2088
|
+
peek (key) {
|
|
2089
|
+
return get(this, key, false)
|
|
2090
|
+
}
|
|
2076
2091
|
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2092
|
+
pop () {
|
|
2093
|
+
const node = this[LRU_LIST].tail;
|
|
2094
|
+
if (!node)
|
|
2095
|
+
return null
|
|
2081
2096
|
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2097
|
+
del(this, node);
|
|
2098
|
+
return node.value
|
|
2099
|
+
}
|
|
2085
2100
|
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2101
|
+
del (key) {
|
|
2102
|
+
del(this, this[CACHE].get(key));
|
|
2103
|
+
}
|
|
2089
2104
|
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2105
|
+
load (arr) {
|
|
2106
|
+
// reset the cache
|
|
2107
|
+
this.reset();
|
|
2108
|
+
|
|
2109
|
+
const now = Date.now();
|
|
2110
|
+
// A previous serialized cache has the most recent items first
|
|
2111
|
+
for (let l = arr.length - 1; l >= 0; l--) {
|
|
2112
|
+
const hit = arr[l];
|
|
2113
|
+
const expiresAt = hit.e || 0;
|
|
2114
|
+
if (expiresAt === 0)
|
|
2115
|
+
// the item was created without expiration in a non aged cache
|
|
2116
|
+
this.set(hit.k, hit.v);
|
|
2117
|
+
else {
|
|
2118
|
+
const maxAge = expiresAt - now;
|
|
2119
|
+
// dont add already expired items
|
|
2120
|
+
if (maxAge > 0) {
|
|
2121
|
+
this.set(hit.k, hit.v, maxAge);
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2111
2126
|
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
}
|
|
2127
|
+
prune () {
|
|
2128
|
+
this[CACHE].forEach((value, key) => get(this, key, false));
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2116
2131
|
|
|
2117
|
-
const get = (self, key, doUse) => {
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
};
|
|
2132
|
+
const get = (self, key, doUse) => {
|
|
2133
|
+
const node = self[CACHE].get(key);
|
|
2134
|
+
if (node) {
|
|
2135
|
+
const hit = node.value;
|
|
2136
|
+
if (isStale(self, hit)) {
|
|
2137
|
+
del(self, node);
|
|
2138
|
+
if (!self[ALLOW_STALE])
|
|
2139
|
+
return undefined
|
|
2140
|
+
} else {
|
|
2141
|
+
if (doUse) {
|
|
2142
|
+
if (self[UPDATE_AGE_ON_GET])
|
|
2143
|
+
node.value.now = Date.now();
|
|
2144
|
+
self[LRU_LIST].unshiftNode(node);
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
return hit.value
|
|
2148
|
+
}
|
|
2149
|
+
};
|
|
2135
2150
|
|
|
2136
|
-
const isStale = (self, hit) => {
|
|
2137
|
-
|
|
2138
|
-
|
|
2151
|
+
const isStale = (self, hit) => {
|
|
2152
|
+
if (!hit || (!hit.maxAge && !self[MAX_AGE]))
|
|
2153
|
+
return false
|
|
2139
2154
|
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
};
|
|
2155
|
+
const diff = Date.now() - hit.now;
|
|
2156
|
+
return hit.maxAge ? diff > hit.maxAge
|
|
2157
|
+
: self[MAX_AGE] && (diff > self[MAX_AGE])
|
|
2158
|
+
};
|
|
2144
2159
|
|
|
2145
|
-
const trim = self => {
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
};
|
|
2160
|
+
const trim = self => {
|
|
2161
|
+
if (self[LENGTH] > self[MAX]) {
|
|
2162
|
+
for (let walker = self[LRU_LIST].tail;
|
|
2163
|
+
self[LENGTH] > self[MAX] && walker !== null;) {
|
|
2164
|
+
// We know that we're about to delete this one, and also
|
|
2165
|
+
// what the next least recently used key will be, so just
|
|
2166
|
+
// go ahead and set it now.
|
|
2167
|
+
const prev = walker.prev;
|
|
2168
|
+
del(self, walker);
|
|
2169
|
+
walker = prev;
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
};
|
|
2158
2173
|
|
|
2159
|
-
const del = (self, node) => {
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2174
|
+
const del = (self, node) => {
|
|
2175
|
+
if (node) {
|
|
2176
|
+
const hit = node.value;
|
|
2177
|
+
if (self[DISPOSE])
|
|
2178
|
+
self[DISPOSE](hit.key, hit.value);
|
|
2164
2179
|
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
};
|
|
2180
|
+
self[LENGTH] -= hit.length;
|
|
2181
|
+
self[CACHE].delete(hit.key);
|
|
2182
|
+
self[LRU_LIST].removeNode(node);
|
|
2183
|
+
}
|
|
2184
|
+
};
|
|
2170
2185
|
|
|
2171
|
-
class Entry {
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
}
|
|
2186
|
+
class Entry {
|
|
2187
|
+
constructor (key, value, length, now, maxAge) {
|
|
2188
|
+
this.key = key;
|
|
2189
|
+
this.value = value;
|
|
2190
|
+
this.length = length;
|
|
2191
|
+
this.now = now;
|
|
2192
|
+
this.maxAge = maxAge || 0;
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2180
2195
|
|
|
2181
|
-
const forEachStep = (self, fn, node, thisp) => {
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
};
|
|
2196
|
+
const forEachStep = (self, fn, node, thisp) => {
|
|
2197
|
+
let hit = node.value;
|
|
2198
|
+
if (isStale(self, hit)) {
|
|
2199
|
+
del(self, node);
|
|
2200
|
+
if (!self[ALLOW_STALE])
|
|
2201
|
+
hit = undefined;
|
|
2202
|
+
}
|
|
2203
|
+
if (hit)
|
|
2204
|
+
fn.call(thisp, hit.value, hit.key, self);
|
|
2205
|
+
};
|
|
2191
2206
|
|
|
2192
|
-
|
|
2207
|
+
lruCache = LRUCache;
|
|
2208
|
+
return lruCache;
|
|
2209
|
+
}
|
|
2193
2210
|
|
|
2194
2211
|
var range;
|
|
2195
2212
|
var hasRequiredRange;
|
|
@@ -2397,7 +2414,7 @@ function requireRange () {
|
|
|
2397
2414
|
|
|
2398
2415
|
range = Range;
|
|
2399
2416
|
|
|
2400
|
-
const LRU =
|
|
2417
|
+
const LRU = requireLruCache();
|
|
2401
2418
|
const cache = new LRU({ max: 1000 });
|
|
2402
2419
|
|
|
2403
2420
|
const parseOptions = parseOptions_1;
|
|
@@ -3802,7 +3819,7 @@ class EasyWorker {
|
|
|
3802
3819
|
this.worker = new Worker(url, {...options});
|
|
3803
3820
|
} else {
|
|
3804
3821
|
return new Promise(async (resolve, reject) => {
|
|
3805
|
-
const {fork} = await import('
|
|
3822
|
+
const {fork} = await import('child_process');
|
|
3806
3823
|
this.worker = fork(url, ['easy-worker-child'], options);
|
|
3807
3824
|
resolve(this);
|
|
3808
3825
|
})
|
|
@@ -3999,7 +4016,7 @@ class Machine {
|
|
|
3999
4016
|
pubsub.subscribe('machine.ready', machineReady);
|
|
4000
4017
|
let pre;
|
|
4001
4018
|
try {
|
|
4002
|
-
const importee = await import('
|
|
4019
|
+
const importee = await import('url');
|
|
4003
4020
|
const url = importee.default;
|
|
4004
4021
|
if (url)
|
|
4005
4022
|
pre = url.fileURLToPath(new URL('.', import.meta.url));
|
|
@@ -4864,9 +4881,9 @@ class Chain extends VersionControl {
|
|
|
4864
4881
|
this.#jail = [];
|
|
4865
4882
|
this.#addTransaction = async (message) => {
|
|
4866
4883
|
const transaction = new TransactionMessage(message);
|
|
4867
|
-
await transaction.hash();
|
|
4884
|
+
const hash = await transaction.hash();
|
|
4868
4885
|
// if (await transactionPoolStore.has(hash)) await transactionPoolStore.delete(hash)
|
|
4869
|
-
debug(`added ${
|
|
4886
|
+
debug(`added ${hash}`);
|
|
4870
4887
|
};
|
|
4871
4888
|
// @ts-ignore
|
|
4872
4889
|
return this.#init();
|