@leofcoin/chain 1.5.44 → 1.5.46

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.
@@ -1388,764 +1388,781 @@ function requireIterator () {
1388
1388
  return iterator;
1389
1389
  }
1390
1390
 
1391
- var yallist = Yallist$1;
1391
+ var yallist;
1392
+ var hasRequiredYallist;
1392
1393
 
1393
- Yallist$1.Node = Node;
1394
- Yallist$1.create = Yallist$1;
1394
+ function requireYallist () {
1395
+ if (hasRequiredYallist) return yallist;
1396
+ hasRequiredYallist = 1;
1397
+ yallist = Yallist;
1395
1398
 
1396
- function Yallist$1 (list) {
1397
- var self = this;
1398
- if (!(self instanceof Yallist$1)) {
1399
- self = new Yallist$1();
1400
- }
1399
+ Yallist.Node = Node;
1400
+ Yallist.create = Yallist;
1401
1401
 
1402
- self.tail = null;
1403
- self.head = null;
1404
- self.length = 0;
1402
+ function Yallist (list) {
1403
+ var self = this;
1404
+ if (!(self instanceof Yallist)) {
1405
+ self = new Yallist();
1406
+ }
1405
1407
 
1406
- if (list && typeof list.forEach === 'function') {
1407
- list.forEach(function (item) {
1408
- self.push(item);
1409
- });
1410
- } else if (arguments.length > 0) {
1411
- for (var i = 0, l = arguments.length; i < l; i++) {
1412
- self.push(arguments[i]);
1413
- }
1414
- }
1408
+ self.tail = null;
1409
+ self.head = null;
1410
+ self.length = 0;
1415
1411
 
1416
- return self
1417
- }
1412
+ if (list && typeof list.forEach === 'function') {
1413
+ list.forEach(function (item) {
1414
+ self.push(item);
1415
+ });
1416
+ } else if (arguments.length > 0) {
1417
+ for (var i = 0, l = arguments.length; i < l; i++) {
1418
+ self.push(arguments[i]);
1419
+ }
1420
+ }
1418
1421
 
1419
- Yallist$1.prototype.removeNode = function (node) {
1420
- if (node.list !== this) {
1421
- throw new Error('removing node which does not belong to this list')
1422
- }
1422
+ return self
1423
+ }
1423
1424
 
1424
- var next = node.next;
1425
- var prev = node.prev;
1425
+ Yallist.prototype.removeNode = function (node) {
1426
+ if (node.list !== this) {
1427
+ throw new Error('removing node which does not belong to this list')
1428
+ }
1426
1429
 
1427
- if (next) {
1428
- next.prev = prev;
1429
- }
1430
+ var next = node.next;
1431
+ var prev = node.prev;
1430
1432
 
1431
- if (prev) {
1432
- prev.next = next;
1433
- }
1433
+ if (next) {
1434
+ next.prev = prev;
1435
+ }
1434
1436
 
1435
- if (node === this.head) {
1436
- this.head = next;
1437
- }
1438
- if (node === this.tail) {
1439
- this.tail = prev;
1440
- }
1437
+ if (prev) {
1438
+ prev.next = next;
1439
+ }
1441
1440
 
1442
- node.list.length--;
1443
- node.next = null;
1444
- node.prev = null;
1445
- node.list = null;
1441
+ if (node === this.head) {
1442
+ this.head = next;
1443
+ }
1444
+ if (node === this.tail) {
1445
+ this.tail = prev;
1446
+ }
1446
1447
 
1447
- return next
1448
- };
1448
+ node.list.length--;
1449
+ node.next = null;
1450
+ node.prev = null;
1451
+ node.list = null;
1449
1452
 
1450
- Yallist$1.prototype.unshiftNode = function (node) {
1451
- if (node === this.head) {
1452
- return
1453
- }
1453
+ return next
1454
+ };
1454
1455
 
1455
- if (node.list) {
1456
- node.list.removeNode(node);
1457
- }
1456
+ Yallist.prototype.unshiftNode = function (node) {
1457
+ if (node === this.head) {
1458
+ return
1459
+ }
1458
1460
 
1459
- var head = this.head;
1460
- node.list = this;
1461
- node.next = head;
1462
- if (head) {
1463
- head.prev = node;
1464
- }
1461
+ if (node.list) {
1462
+ node.list.removeNode(node);
1463
+ }
1465
1464
 
1466
- this.head = node;
1467
- if (!this.tail) {
1468
- this.tail = node;
1469
- }
1470
- this.length++;
1471
- };
1465
+ var head = this.head;
1466
+ node.list = this;
1467
+ node.next = head;
1468
+ if (head) {
1469
+ head.prev = node;
1470
+ }
1472
1471
 
1473
- Yallist$1.prototype.pushNode = function (node) {
1474
- if (node === this.tail) {
1475
- return
1476
- }
1472
+ this.head = node;
1473
+ if (!this.tail) {
1474
+ this.tail = node;
1475
+ }
1476
+ this.length++;
1477
+ };
1477
1478
 
1478
- if (node.list) {
1479
- node.list.removeNode(node);
1480
- }
1479
+ Yallist.prototype.pushNode = function (node) {
1480
+ if (node === this.tail) {
1481
+ return
1482
+ }
1481
1483
 
1482
- var tail = this.tail;
1483
- node.list = this;
1484
- node.prev = tail;
1485
- if (tail) {
1486
- tail.next = node;
1487
- }
1484
+ if (node.list) {
1485
+ node.list.removeNode(node);
1486
+ }
1488
1487
 
1489
- this.tail = node;
1490
- if (!this.head) {
1491
- this.head = node;
1492
- }
1493
- this.length++;
1494
- };
1488
+ var tail = this.tail;
1489
+ node.list = this;
1490
+ node.prev = tail;
1491
+ if (tail) {
1492
+ tail.next = node;
1493
+ }
1495
1494
 
1496
- Yallist$1.prototype.push = function () {
1497
- for (var i = 0, l = arguments.length; i < l; i++) {
1498
- push(this, arguments[i]);
1499
- }
1500
- return this.length
1501
- };
1495
+ this.tail = node;
1496
+ if (!this.head) {
1497
+ this.head = node;
1498
+ }
1499
+ this.length++;
1500
+ };
1502
1501
 
1503
- Yallist$1.prototype.unshift = function () {
1504
- for (var i = 0, l = arguments.length; i < l; i++) {
1505
- unshift(this, arguments[i]);
1506
- }
1507
- return this.length
1508
- };
1502
+ Yallist.prototype.push = function () {
1503
+ for (var i = 0, l = arguments.length; i < l; i++) {
1504
+ push(this, arguments[i]);
1505
+ }
1506
+ return this.length
1507
+ };
1509
1508
 
1510
- Yallist$1.prototype.pop = function () {
1511
- if (!this.tail) {
1512
- return undefined
1513
- }
1509
+ Yallist.prototype.unshift = function () {
1510
+ for (var i = 0, l = arguments.length; i < l; i++) {
1511
+ unshift(this, arguments[i]);
1512
+ }
1513
+ return this.length
1514
+ };
1514
1515
 
1515
- var res = this.tail.value;
1516
- this.tail = this.tail.prev;
1517
- if (this.tail) {
1518
- this.tail.next = null;
1519
- } else {
1520
- this.head = null;
1521
- }
1522
- this.length--;
1523
- return res
1524
- };
1516
+ Yallist.prototype.pop = function () {
1517
+ if (!this.tail) {
1518
+ return undefined
1519
+ }
1525
1520
 
1526
- Yallist$1.prototype.shift = function () {
1527
- if (!this.head) {
1528
- return undefined
1529
- }
1521
+ var res = this.tail.value;
1522
+ this.tail = this.tail.prev;
1523
+ if (this.tail) {
1524
+ this.tail.next = null;
1525
+ } else {
1526
+ this.head = null;
1527
+ }
1528
+ this.length--;
1529
+ return res
1530
+ };
1530
1531
 
1531
- var res = this.head.value;
1532
- this.head = this.head.next;
1533
- if (this.head) {
1534
- this.head.prev = null;
1535
- } else {
1536
- this.tail = null;
1537
- }
1538
- this.length--;
1539
- return res
1540
- };
1532
+ Yallist.prototype.shift = function () {
1533
+ if (!this.head) {
1534
+ return undefined
1535
+ }
1541
1536
 
1542
- Yallist$1.prototype.forEach = function (fn, thisp) {
1543
- thisp = thisp || this;
1544
- for (var walker = this.head, i = 0; walker !== null; i++) {
1545
- fn.call(thisp, walker.value, i, this);
1546
- walker = walker.next;
1547
- }
1548
- };
1537
+ var res = this.head.value;
1538
+ this.head = this.head.next;
1539
+ if (this.head) {
1540
+ this.head.prev = null;
1541
+ } else {
1542
+ this.tail = null;
1543
+ }
1544
+ this.length--;
1545
+ return res
1546
+ };
1549
1547
 
1550
- Yallist$1.prototype.forEachReverse = function (fn, thisp) {
1551
- thisp = thisp || this;
1552
- for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
1553
- fn.call(thisp, walker.value, i, this);
1554
- walker = walker.prev;
1555
- }
1556
- };
1548
+ Yallist.prototype.forEach = function (fn, thisp) {
1549
+ thisp = thisp || this;
1550
+ for (var walker = this.head, i = 0; walker !== null; i++) {
1551
+ fn.call(thisp, walker.value, i, this);
1552
+ walker = walker.next;
1553
+ }
1554
+ };
1557
1555
 
1558
- Yallist$1.prototype.get = function (n) {
1559
- for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
1560
- // abort out of the list early if we hit a cycle
1561
- walker = walker.next;
1562
- }
1563
- if (i === n && walker !== null) {
1564
- return walker.value
1565
- }
1566
- };
1556
+ Yallist.prototype.forEachReverse = function (fn, thisp) {
1557
+ thisp = thisp || this;
1558
+ for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
1559
+ fn.call(thisp, walker.value, i, this);
1560
+ walker = walker.prev;
1561
+ }
1562
+ };
1567
1563
 
1568
- Yallist$1.prototype.getReverse = function (n) {
1569
- for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
1570
- // abort out of the list early if we hit a cycle
1571
- walker = walker.prev;
1572
- }
1573
- if (i === n && walker !== null) {
1574
- return walker.value
1575
- }
1576
- };
1564
+ Yallist.prototype.get = function (n) {
1565
+ for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
1566
+ // abort out of the list early if we hit a cycle
1567
+ walker = walker.next;
1568
+ }
1569
+ if (i === n && walker !== null) {
1570
+ return walker.value
1571
+ }
1572
+ };
1577
1573
 
1578
- Yallist$1.prototype.map = function (fn, thisp) {
1579
- thisp = thisp || this;
1580
- var res = new Yallist$1();
1581
- for (var walker = this.head; walker !== null;) {
1582
- res.push(fn.call(thisp, walker.value, this));
1583
- walker = walker.next;
1584
- }
1585
- return res
1586
- };
1574
+ Yallist.prototype.getReverse = function (n) {
1575
+ for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
1576
+ // abort out of the list early if we hit a cycle
1577
+ walker = walker.prev;
1578
+ }
1579
+ if (i === n && walker !== null) {
1580
+ return walker.value
1581
+ }
1582
+ };
1587
1583
 
1588
- Yallist$1.prototype.mapReverse = function (fn, thisp) {
1589
- thisp = thisp || this;
1590
- var res = new Yallist$1();
1591
- for (var walker = this.tail; walker !== null;) {
1592
- res.push(fn.call(thisp, walker.value, this));
1593
- walker = walker.prev;
1594
- }
1595
- return res
1596
- };
1584
+ Yallist.prototype.map = function (fn, thisp) {
1585
+ thisp = thisp || this;
1586
+ var res = new Yallist();
1587
+ for (var walker = this.head; walker !== null;) {
1588
+ res.push(fn.call(thisp, walker.value, this));
1589
+ walker = walker.next;
1590
+ }
1591
+ return res
1592
+ };
1597
1593
 
1598
- Yallist$1.prototype.reduce = function (fn, initial) {
1599
- var acc;
1600
- var walker = this.head;
1601
- if (arguments.length > 1) {
1602
- acc = initial;
1603
- } else if (this.head) {
1604
- walker = this.head.next;
1605
- acc = this.head.value;
1606
- } else {
1607
- throw new TypeError('Reduce of empty list with no initial value')
1608
- }
1594
+ Yallist.prototype.mapReverse = function (fn, thisp) {
1595
+ thisp = thisp || this;
1596
+ var res = new Yallist();
1597
+ for (var walker = this.tail; walker !== null;) {
1598
+ res.push(fn.call(thisp, walker.value, this));
1599
+ walker = walker.prev;
1600
+ }
1601
+ return res
1602
+ };
1609
1603
 
1610
- for (var i = 0; walker !== null; i++) {
1611
- acc = fn(acc, walker.value, i);
1612
- walker = walker.next;
1613
- }
1604
+ Yallist.prototype.reduce = function (fn, initial) {
1605
+ var acc;
1606
+ var walker = this.head;
1607
+ if (arguments.length > 1) {
1608
+ acc = initial;
1609
+ } else if (this.head) {
1610
+ walker = this.head.next;
1611
+ acc = this.head.value;
1612
+ } else {
1613
+ throw new TypeError('Reduce of empty list with no initial value')
1614
+ }
1614
1615
 
1615
- return acc
1616
- };
1616
+ for (var i = 0; walker !== null; i++) {
1617
+ acc = fn(acc, walker.value, i);
1618
+ walker = walker.next;
1619
+ }
1617
1620
 
1618
- Yallist$1.prototype.reduceReverse = function (fn, initial) {
1619
- var acc;
1620
- var walker = this.tail;
1621
- if (arguments.length > 1) {
1622
- acc = initial;
1623
- } else if (this.tail) {
1624
- walker = this.tail.prev;
1625
- acc = this.tail.value;
1626
- } else {
1627
- throw new TypeError('Reduce of empty list with no initial value')
1628
- }
1621
+ return acc
1622
+ };
1629
1623
 
1630
- for (var i = this.length - 1; walker !== null; i--) {
1631
- acc = fn(acc, walker.value, i);
1632
- walker = walker.prev;
1633
- }
1624
+ Yallist.prototype.reduceReverse = function (fn, initial) {
1625
+ var acc;
1626
+ var walker = this.tail;
1627
+ if (arguments.length > 1) {
1628
+ acc = initial;
1629
+ } else if (this.tail) {
1630
+ walker = this.tail.prev;
1631
+ acc = this.tail.value;
1632
+ } else {
1633
+ throw new TypeError('Reduce of empty list with no initial value')
1634
+ }
1634
1635
 
1635
- return acc
1636
- };
1636
+ for (var i = this.length - 1; walker !== null; i--) {
1637
+ acc = fn(acc, walker.value, i);
1638
+ walker = walker.prev;
1639
+ }
1637
1640
 
1638
- Yallist$1.prototype.toArray = function () {
1639
- var arr = new Array(this.length);
1640
- for (var i = 0, walker = this.head; walker !== null; i++) {
1641
- arr[i] = walker.value;
1642
- walker = walker.next;
1643
- }
1644
- return arr
1645
- };
1641
+ return acc
1642
+ };
1646
1643
 
1647
- Yallist$1.prototype.toArrayReverse = function () {
1648
- var arr = new Array(this.length);
1649
- for (var i = 0, walker = this.tail; walker !== null; i++) {
1650
- arr[i] = walker.value;
1651
- walker = walker.prev;
1652
- }
1653
- return arr
1654
- };
1644
+ Yallist.prototype.toArray = function () {
1645
+ var arr = new Array(this.length);
1646
+ for (var i = 0, walker = this.head; walker !== null; i++) {
1647
+ arr[i] = walker.value;
1648
+ walker = walker.next;
1649
+ }
1650
+ return arr
1651
+ };
1655
1652
 
1656
- Yallist$1.prototype.slice = function (from, to) {
1657
- to = to || this.length;
1658
- if (to < 0) {
1659
- to += this.length;
1660
- }
1661
- from = from || 0;
1662
- if (from < 0) {
1663
- from += this.length;
1664
- }
1665
- var ret = new Yallist$1();
1666
- if (to < from || to < 0) {
1667
- return ret
1668
- }
1669
- if (from < 0) {
1670
- from = 0;
1671
- }
1672
- if (to > this.length) {
1673
- to = this.length;
1674
- }
1675
- for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
1676
- walker = walker.next;
1677
- }
1678
- for (; walker !== null && i < to; i++, walker = walker.next) {
1679
- ret.push(walker.value);
1680
- }
1681
- return ret
1682
- };
1653
+ Yallist.prototype.toArrayReverse = function () {
1654
+ var arr = new Array(this.length);
1655
+ for (var i = 0, walker = this.tail; walker !== null; i++) {
1656
+ arr[i] = walker.value;
1657
+ walker = walker.prev;
1658
+ }
1659
+ return arr
1660
+ };
1683
1661
 
1684
- Yallist$1.prototype.sliceReverse = function (from, to) {
1685
- to = to || this.length;
1686
- if (to < 0) {
1687
- to += this.length;
1688
- }
1689
- from = from || 0;
1690
- if (from < 0) {
1691
- from += this.length;
1692
- }
1693
- var ret = new Yallist$1();
1694
- if (to < from || to < 0) {
1695
- return ret
1696
- }
1697
- if (from < 0) {
1698
- from = 0;
1699
- }
1700
- if (to > this.length) {
1701
- to = this.length;
1702
- }
1703
- for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
1704
- walker = walker.prev;
1705
- }
1706
- for (; walker !== null && i > from; i--, walker = walker.prev) {
1707
- ret.push(walker.value);
1708
- }
1709
- return ret
1710
- };
1662
+ Yallist.prototype.slice = function (from, to) {
1663
+ to = to || this.length;
1664
+ if (to < 0) {
1665
+ to += this.length;
1666
+ }
1667
+ from = from || 0;
1668
+ if (from < 0) {
1669
+ from += this.length;
1670
+ }
1671
+ var ret = new Yallist();
1672
+ if (to < from || to < 0) {
1673
+ return ret
1674
+ }
1675
+ if (from < 0) {
1676
+ from = 0;
1677
+ }
1678
+ if (to > this.length) {
1679
+ to = this.length;
1680
+ }
1681
+ for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
1682
+ walker = walker.next;
1683
+ }
1684
+ for (; walker !== null && i < to; i++, walker = walker.next) {
1685
+ ret.push(walker.value);
1686
+ }
1687
+ return ret
1688
+ };
1711
1689
 
1712
- Yallist$1.prototype.splice = function (start, deleteCount, ...nodes) {
1713
- if (start > this.length) {
1714
- start = this.length - 1;
1715
- }
1716
- if (start < 0) {
1717
- start = this.length + start;
1718
- }
1690
+ Yallist.prototype.sliceReverse = function (from, to) {
1691
+ to = to || this.length;
1692
+ if (to < 0) {
1693
+ to += this.length;
1694
+ }
1695
+ from = from || 0;
1696
+ if (from < 0) {
1697
+ from += this.length;
1698
+ }
1699
+ var ret = new Yallist();
1700
+ if (to < from || to < 0) {
1701
+ return ret
1702
+ }
1703
+ if (from < 0) {
1704
+ from = 0;
1705
+ }
1706
+ if (to > this.length) {
1707
+ to = this.length;
1708
+ }
1709
+ for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
1710
+ walker = walker.prev;
1711
+ }
1712
+ for (; walker !== null && i > from; i--, walker = walker.prev) {
1713
+ ret.push(walker.value);
1714
+ }
1715
+ return ret
1716
+ };
1719
1717
 
1720
- for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
1721
- walker = walker.next;
1722
- }
1718
+ Yallist.prototype.splice = function (start, deleteCount, ...nodes) {
1719
+ if (start > this.length) {
1720
+ start = this.length - 1;
1721
+ }
1722
+ if (start < 0) {
1723
+ start = this.length + start;
1724
+ }
1723
1725
 
1724
- var ret = [];
1725
- for (var i = 0; walker && i < deleteCount; i++) {
1726
- ret.push(walker.value);
1727
- walker = this.removeNode(walker);
1728
- }
1729
- if (walker === null) {
1730
- walker = this.tail;
1731
- }
1726
+ for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
1727
+ walker = walker.next;
1728
+ }
1732
1729
 
1733
- if (walker !== this.head && walker !== this.tail) {
1734
- walker = walker.prev;
1735
- }
1730
+ var ret = [];
1731
+ for (var i = 0; walker && i < deleteCount; i++) {
1732
+ ret.push(walker.value);
1733
+ walker = this.removeNode(walker);
1734
+ }
1735
+ if (walker === null) {
1736
+ walker = this.tail;
1737
+ }
1736
1738
 
1737
- for (var i = 0; i < nodes.length; i++) {
1738
- walker = insert(this, walker, nodes[i]);
1739
- }
1740
- return ret;
1741
- };
1739
+ if (walker !== this.head && walker !== this.tail) {
1740
+ walker = walker.prev;
1741
+ }
1742
1742
 
1743
- Yallist$1.prototype.reverse = function () {
1744
- var head = this.head;
1745
- var tail = this.tail;
1746
- for (var walker = head; walker !== null; walker = walker.prev) {
1747
- var p = walker.prev;
1748
- walker.prev = walker.next;
1749
- walker.next = p;
1750
- }
1751
- this.head = tail;
1752
- this.tail = head;
1753
- return this
1754
- };
1743
+ for (var i = 0; i < nodes.length; i++) {
1744
+ walker = insert(this, walker, nodes[i]);
1745
+ }
1746
+ return ret;
1747
+ };
1755
1748
 
1756
- function insert (self, node, value) {
1757
- var inserted = node === self.head ?
1758
- new Node(value, null, node, self) :
1759
- new Node(value, node, node.next, self);
1749
+ Yallist.prototype.reverse = function () {
1750
+ var head = this.head;
1751
+ var tail = this.tail;
1752
+ for (var walker = head; walker !== null; walker = walker.prev) {
1753
+ var p = walker.prev;
1754
+ walker.prev = walker.next;
1755
+ walker.next = p;
1756
+ }
1757
+ this.head = tail;
1758
+ this.tail = head;
1759
+ return this
1760
+ };
1760
1761
 
1761
- if (inserted.next === null) {
1762
- self.tail = inserted;
1763
- }
1764
- if (inserted.prev === null) {
1765
- self.head = inserted;
1766
- }
1762
+ function insert (self, node, value) {
1763
+ var inserted = node === self.head ?
1764
+ new Node(value, null, node, self) :
1765
+ new Node(value, node, node.next, self);
1767
1766
 
1768
- self.length++;
1767
+ if (inserted.next === null) {
1768
+ self.tail = inserted;
1769
+ }
1770
+ if (inserted.prev === null) {
1771
+ self.head = inserted;
1772
+ }
1769
1773
 
1770
- return inserted
1771
- }
1774
+ self.length++;
1772
1775
 
1773
- function push (self, item) {
1774
- self.tail = new Node(item, self.tail, null, self);
1775
- if (!self.head) {
1776
- self.head = self.tail;
1777
- }
1778
- self.length++;
1779
- }
1776
+ return inserted
1777
+ }
1780
1778
 
1781
- function unshift (self, item) {
1782
- self.head = new Node(item, null, self.head, self);
1783
- if (!self.tail) {
1784
- self.tail = self.head;
1785
- }
1786
- self.length++;
1787
- }
1779
+ function push (self, item) {
1780
+ self.tail = new Node(item, self.tail, null, self);
1781
+ if (!self.head) {
1782
+ self.head = self.tail;
1783
+ }
1784
+ self.length++;
1785
+ }
1788
1786
 
1789
- function Node (value, prev, next, list) {
1790
- if (!(this instanceof Node)) {
1791
- return new Node(value, prev, next, list)
1792
- }
1787
+ function unshift (self, item) {
1788
+ self.head = new Node(item, null, self.head, self);
1789
+ if (!self.tail) {
1790
+ self.tail = self.head;
1791
+ }
1792
+ self.length++;
1793
+ }
1793
1794
 
1794
- this.list = list;
1795
- this.value = value;
1795
+ function Node (value, prev, next, list) {
1796
+ if (!(this instanceof Node)) {
1797
+ return new Node(value, prev, next, list)
1798
+ }
1796
1799
 
1797
- if (prev) {
1798
- prev.next = this;
1799
- this.prev = prev;
1800
- } else {
1801
- this.prev = null;
1802
- }
1800
+ this.list = list;
1801
+ this.value = value;
1803
1802
 
1804
- if (next) {
1805
- next.prev = this;
1806
- this.next = next;
1807
- } else {
1808
- this.next = null;
1809
- }
1803
+ if (prev) {
1804
+ prev.next = this;
1805
+ this.prev = prev;
1806
+ } else {
1807
+ this.prev = null;
1808
+ }
1809
+
1810
+ if (next) {
1811
+ next.prev = this;
1812
+ this.next = next;
1813
+ } else {
1814
+ this.next = null;
1815
+ }
1816
+ }
1817
+
1818
+ try {
1819
+ // add if support for Symbol.iterator is present
1820
+ requireIterator()(Yallist);
1821
+ } catch (er) {}
1822
+ return yallist;
1810
1823
  }
1811
1824
 
1812
- try {
1813
- // add if support for Symbol.iterator is present
1814
- requireIterator()(Yallist$1);
1815
- } catch (er) {}
1816
-
1817
- // A linked list to keep track of recently-used-ness
1818
- const Yallist = yallist;
1819
-
1820
- const MAX = Symbol('max');
1821
- const LENGTH = Symbol('length');
1822
- const LENGTH_CALCULATOR = Symbol('lengthCalculator');
1823
- const ALLOW_STALE = Symbol('allowStale');
1824
- const MAX_AGE = Symbol('maxAge');
1825
- const DISPOSE = Symbol('dispose');
1826
- const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet');
1827
- const LRU_LIST = Symbol('lruList');
1828
- const CACHE = Symbol('cache');
1829
- const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
1830
-
1831
- const naiveLength = () => 1;
1832
-
1833
- // lruList is a yallist where the head is the youngest
1834
- // item, and the tail is the oldest. the list contains the Hit
1835
- // objects as the entries.
1836
- // Each Hit object has a reference to its Yallist.Node. This
1837
- // never changes.
1838
- //
1839
- // cache is a Map (or PseudoMap) that matches the keys to
1840
- // the Yallist.Node object.
1841
- class LRUCache {
1842
- constructor (options) {
1843
- if (typeof options === 'number')
1844
- options = { max: options };
1845
-
1846
- if (!options)
1847
- options = {};
1848
-
1849
- if (options.max && (typeof options.max !== 'number' || options.max < 0))
1850
- throw new TypeError('max must be a non-negative number')
1851
- // Kind of weird to have a default max of Infinity, but oh well.
1852
- this[MAX] = options.max || Infinity;
1853
-
1854
- const lc = options.length || naiveLength;
1855
- this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc;
1856
- this[ALLOW_STALE] = options.stale || false;
1857
- if (options.maxAge && typeof options.maxAge !== 'number')
1858
- throw new TypeError('maxAge must be a number')
1859
- this[MAX_AGE] = options.maxAge || 0;
1860
- this[DISPOSE] = options.dispose;
1861
- this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
1862
- this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false;
1863
- this.reset();
1864
- }
1825
+ var lruCache;
1826
+ var hasRequiredLruCache;
1827
+
1828
+ function requireLruCache () {
1829
+ if (hasRequiredLruCache) return lruCache;
1830
+ hasRequiredLruCache = 1;
1831
+
1832
+ // A linked list to keep track of recently-used-ness
1833
+ const Yallist = requireYallist();
1834
+
1835
+ const MAX = Symbol('max');
1836
+ const LENGTH = Symbol('length');
1837
+ const LENGTH_CALCULATOR = Symbol('lengthCalculator');
1838
+ const ALLOW_STALE = Symbol('allowStale');
1839
+ const MAX_AGE = Symbol('maxAge');
1840
+ const DISPOSE = Symbol('dispose');
1841
+ const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet');
1842
+ const LRU_LIST = Symbol('lruList');
1843
+ const CACHE = Symbol('cache');
1844
+ const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
1845
+
1846
+ const naiveLength = () => 1;
1847
+
1848
+ // lruList is a yallist where the head is the youngest
1849
+ // item, and the tail is the oldest. the list contains the Hit
1850
+ // objects as the entries.
1851
+ // Each Hit object has a reference to its Yallist.Node. This
1852
+ // never changes.
1853
+ //
1854
+ // cache is a Map (or PseudoMap) that matches the keys to
1855
+ // the Yallist.Node object.
1856
+ class LRUCache {
1857
+ constructor (options) {
1858
+ if (typeof options === 'number')
1859
+ options = { max: options };
1860
+
1861
+ if (!options)
1862
+ options = {};
1863
+
1864
+ if (options.max && (typeof options.max !== 'number' || options.max < 0))
1865
+ throw new TypeError('max must be a non-negative number')
1866
+ // Kind of weird to have a default max of Infinity, but oh well.
1867
+ this[MAX] = options.max || Infinity;
1868
+
1869
+ const lc = options.length || naiveLength;
1870
+ this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc;
1871
+ this[ALLOW_STALE] = options.stale || false;
1872
+ if (options.maxAge && typeof options.maxAge !== 'number')
1873
+ throw new TypeError('maxAge must be a number')
1874
+ this[MAX_AGE] = options.maxAge || 0;
1875
+ this[DISPOSE] = options.dispose;
1876
+ this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
1877
+ this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false;
1878
+ this.reset();
1879
+ }
1865
1880
 
1866
- // resize the cache when the max changes.
1867
- set max (mL) {
1868
- if (typeof mL !== 'number' || mL < 0)
1869
- throw new TypeError('max must be a non-negative number')
1881
+ // resize the cache when the max changes.
1882
+ set max (mL) {
1883
+ if (typeof mL !== 'number' || mL < 0)
1884
+ throw new TypeError('max must be a non-negative number')
1870
1885
 
1871
- this[MAX] = mL || Infinity;
1872
- trim(this);
1873
- }
1874
- get max () {
1875
- return this[MAX]
1876
- }
1886
+ this[MAX] = mL || Infinity;
1887
+ trim(this);
1888
+ }
1889
+ get max () {
1890
+ return this[MAX]
1891
+ }
1877
1892
 
1878
- set allowStale (allowStale) {
1879
- this[ALLOW_STALE] = !!allowStale;
1880
- }
1881
- get allowStale () {
1882
- return this[ALLOW_STALE]
1883
- }
1893
+ set allowStale (allowStale) {
1894
+ this[ALLOW_STALE] = !!allowStale;
1895
+ }
1896
+ get allowStale () {
1897
+ return this[ALLOW_STALE]
1898
+ }
1884
1899
 
1885
- set maxAge (mA) {
1886
- if (typeof mA !== 'number')
1887
- throw new TypeError('maxAge must be a non-negative number')
1900
+ set maxAge (mA) {
1901
+ if (typeof mA !== 'number')
1902
+ throw new TypeError('maxAge must be a non-negative number')
1888
1903
 
1889
- this[MAX_AGE] = mA;
1890
- trim(this);
1891
- }
1892
- get maxAge () {
1893
- return this[MAX_AGE]
1894
- }
1904
+ this[MAX_AGE] = mA;
1905
+ trim(this);
1906
+ }
1907
+ get maxAge () {
1908
+ return this[MAX_AGE]
1909
+ }
1895
1910
 
1896
- // resize the cache when the lengthCalculator changes.
1897
- set lengthCalculator (lC) {
1898
- if (typeof lC !== 'function')
1899
- lC = naiveLength;
1900
-
1901
- if (lC !== this[LENGTH_CALCULATOR]) {
1902
- this[LENGTH_CALCULATOR] = lC;
1903
- this[LENGTH] = 0;
1904
- this[LRU_LIST].forEach(hit => {
1905
- hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
1906
- this[LENGTH] += hit.length;
1907
- });
1908
- }
1909
- trim(this);
1910
- }
1911
- get lengthCalculator () { return this[LENGTH_CALCULATOR] }
1911
+ // resize the cache when the lengthCalculator changes.
1912
+ set lengthCalculator (lC) {
1913
+ if (typeof lC !== 'function')
1914
+ lC = naiveLength;
1915
+
1916
+ if (lC !== this[LENGTH_CALCULATOR]) {
1917
+ this[LENGTH_CALCULATOR] = lC;
1918
+ this[LENGTH] = 0;
1919
+ this[LRU_LIST].forEach(hit => {
1920
+ hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
1921
+ this[LENGTH] += hit.length;
1922
+ });
1923
+ }
1924
+ trim(this);
1925
+ }
1926
+ get lengthCalculator () { return this[LENGTH_CALCULATOR] }
1912
1927
 
1913
- get length () { return this[LENGTH] }
1914
- get itemCount () { return this[LRU_LIST].length }
1928
+ get length () { return this[LENGTH] }
1929
+ get itemCount () { return this[LRU_LIST].length }
1915
1930
 
1916
- rforEach (fn, thisp) {
1917
- thisp = thisp || this;
1918
- for (let walker = this[LRU_LIST].tail; walker !== null;) {
1919
- const prev = walker.prev;
1920
- forEachStep(this, fn, walker, thisp);
1921
- walker = prev;
1922
- }
1923
- }
1931
+ rforEach (fn, thisp) {
1932
+ thisp = thisp || this;
1933
+ for (let walker = this[LRU_LIST].tail; walker !== null;) {
1934
+ const prev = walker.prev;
1935
+ forEachStep(this, fn, walker, thisp);
1936
+ walker = prev;
1937
+ }
1938
+ }
1924
1939
 
1925
- forEach (fn, thisp) {
1926
- thisp = thisp || this;
1927
- for (let walker = this[LRU_LIST].head; walker !== null;) {
1928
- const next = walker.next;
1929
- forEachStep(this, fn, walker, thisp);
1930
- walker = next;
1931
- }
1932
- }
1940
+ forEach (fn, thisp) {
1941
+ thisp = thisp || this;
1942
+ for (let walker = this[LRU_LIST].head; walker !== null;) {
1943
+ const next = walker.next;
1944
+ forEachStep(this, fn, walker, thisp);
1945
+ walker = next;
1946
+ }
1947
+ }
1933
1948
 
1934
- keys () {
1935
- return this[LRU_LIST].toArray().map(k => k.key)
1936
- }
1949
+ keys () {
1950
+ return this[LRU_LIST].toArray().map(k => k.key)
1951
+ }
1937
1952
 
1938
- values () {
1939
- return this[LRU_LIST].toArray().map(k => k.value)
1940
- }
1953
+ values () {
1954
+ return this[LRU_LIST].toArray().map(k => k.value)
1955
+ }
1941
1956
 
1942
- reset () {
1943
- if (this[DISPOSE] &&
1944
- this[LRU_LIST] &&
1945
- this[LRU_LIST].length) {
1946
- this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value));
1947
- }
1957
+ reset () {
1958
+ if (this[DISPOSE] &&
1959
+ this[LRU_LIST] &&
1960
+ this[LRU_LIST].length) {
1961
+ this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value));
1962
+ }
1948
1963
 
1949
- this[CACHE] = new Map(); // hash of items by key
1950
- this[LRU_LIST] = new Yallist(); // list of items in order of use recency
1951
- this[LENGTH] = 0; // length of items in the list
1952
- }
1964
+ this[CACHE] = new Map(); // hash of items by key
1965
+ this[LRU_LIST] = new Yallist(); // list of items in order of use recency
1966
+ this[LENGTH] = 0; // length of items in the list
1967
+ }
1953
1968
 
1954
- dump () {
1955
- return this[LRU_LIST].map(hit =>
1956
- isStale(this, hit) ? false : {
1957
- k: hit.key,
1958
- v: hit.value,
1959
- e: hit.now + (hit.maxAge || 0)
1960
- }).toArray().filter(h => h)
1961
- }
1969
+ dump () {
1970
+ return this[LRU_LIST].map(hit =>
1971
+ isStale(this, hit) ? false : {
1972
+ k: hit.key,
1973
+ v: hit.value,
1974
+ e: hit.now + (hit.maxAge || 0)
1975
+ }).toArray().filter(h => h)
1976
+ }
1962
1977
 
1963
- dumpLru () {
1964
- return this[LRU_LIST]
1965
- }
1978
+ dumpLru () {
1979
+ return this[LRU_LIST]
1980
+ }
1966
1981
 
1967
- set (key, value, maxAge) {
1968
- maxAge = maxAge || this[MAX_AGE];
1982
+ set (key, value, maxAge) {
1983
+ maxAge = maxAge || this[MAX_AGE];
1969
1984
 
1970
- if (maxAge && typeof maxAge !== 'number')
1971
- throw new TypeError('maxAge must be a number')
1985
+ if (maxAge && typeof maxAge !== 'number')
1986
+ throw new TypeError('maxAge must be a number')
1972
1987
 
1973
- const now = maxAge ? Date.now() : 0;
1974
- const len = this[LENGTH_CALCULATOR](value, key);
1988
+ const now = maxAge ? Date.now() : 0;
1989
+ const len = this[LENGTH_CALCULATOR](value, key);
1975
1990
 
1976
- if (this[CACHE].has(key)) {
1977
- if (len > this[MAX]) {
1978
- del(this, this[CACHE].get(key));
1979
- return false
1980
- }
1991
+ if (this[CACHE].has(key)) {
1992
+ if (len > this[MAX]) {
1993
+ del(this, this[CACHE].get(key));
1994
+ return false
1995
+ }
1981
1996
 
1982
- const node = this[CACHE].get(key);
1983
- const item = node.value;
1997
+ const node = this[CACHE].get(key);
1998
+ const item = node.value;
1984
1999
 
1985
- // dispose of the old one before overwriting
1986
- // split out into 2 ifs for better coverage tracking
1987
- if (this[DISPOSE]) {
1988
- if (!this[NO_DISPOSE_ON_SET])
1989
- this[DISPOSE](key, item.value);
1990
- }
2000
+ // dispose of the old one before overwriting
2001
+ // split out into 2 ifs for better coverage tracking
2002
+ if (this[DISPOSE]) {
2003
+ if (!this[NO_DISPOSE_ON_SET])
2004
+ this[DISPOSE](key, item.value);
2005
+ }
1991
2006
 
1992
- item.now = now;
1993
- item.maxAge = maxAge;
1994
- item.value = value;
1995
- this[LENGTH] += len - item.length;
1996
- item.length = len;
1997
- this.get(key);
1998
- trim(this);
1999
- return true
2000
- }
2007
+ item.now = now;
2008
+ item.maxAge = maxAge;
2009
+ item.value = value;
2010
+ this[LENGTH] += len - item.length;
2011
+ item.length = len;
2012
+ this.get(key);
2013
+ trim(this);
2014
+ return true
2015
+ }
2001
2016
 
2002
- const hit = new Entry(key, value, len, now, maxAge);
2017
+ const hit = new Entry(key, value, len, now, maxAge);
2003
2018
 
2004
- // oversized objects fall out of cache automatically.
2005
- if (hit.length > this[MAX]) {
2006
- if (this[DISPOSE])
2007
- this[DISPOSE](key, value);
2019
+ // oversized objects fall out of cache automatically.
2020
+ if (hit.length > this[MAX]) {
2021
+ if (this[DISPOSE])
2022
+ this[DISPOSE](key, value);
2008
2023
 
2009
- return false
2010
- }
2024
+ return false
2025
+ }
2011
2026
 
2012
- this[LENGTH] += hit.length;
2013
- this[LRU_LIST].unshift(hit);
2014
- this[CACHE].set(key, this[LRU_LIST].head);
2015
- trim(this);
2016
- return true
2017
- }
2027
+ this[LENGTH] += hit.length;
2028
+ this[LRU_LIST].unshift(hit);
2029
+ this[CACHE].set(key, this[LRU_LIST].head);
2030
+ trim(this);
2031
+ return true
2032
+ }
2018
2033
 
2019
- has (key) {
2020
- if (!this[CACHE].has(key)) return false
2021
- const hit = this[CACHE].get(key).value;
2022
- return !isStale(this, hit)
2023
- }
2034
+ has (key) {
2035
+ if (!this[CACHE].has(key)) return false
2036
+ const hit = this[CACHE].get(key).value;
2037
+ return !isStale(this, hit)
2038
+ }
2024
2039
 
2025
- get (key) {
2026
- return get(this, key, true)
2027
- }
2040
+ get (key) {
2041
+ return get(this, key, true)
2042
+ }
2028
2043
 
2029
- peek (key) {
2030
- return get(this, key, false)
2031
- }
2044
+ peek (key) {
2045
+ return get(this, key, false)
2046
+ }
2032
2047
 
2033
- pop () {
2034
- const node = this[LRU_LIST].tail;
2035
- if (!node)
2036
- return null
2048
+ pop () {
2049
+ const node = this[LRU_LIST].tail;
2050
+ if (!node)
2051
+ return null
2037
2052
 
2038
- del(this, node);
2039
- return node.value
2040
- }
2053
+ del(this, node);
2054
+ return node.value
2055
+ }
2041
2056
 
2042
- del (key) {
2043
- del(this, this[CACHE].get(key));
2044
- }
2057
+ del (key) {
2058
+ del(this, this[CACHE].get(key));
2059
+ }
2045
2060
 
2046
- load (arr) {
2047
- // reset the cache
2048
- this.reset();
2049
-
2050
- const now = Date.now();
2051
- // A previous serialized cache has the most recent items first
2052
- for (let l = arr.length - 1; l >= 0; l--) {
2053
- const hit = arr[l];
2054
- const expiresAt = hit.e || 0;
2055
- if (expiresAt === 0)
2056
- // the item was created without expiration in a non aged cache
2057
- this.set(hit.k, hit.v);
2058
- else {
2059
- const maxAge = expiresAt - now;
2060
- // dont add already expired items
2061
- if (maxAge > 0) {
2062
- this.set(hit.k, hit.v, maxAge);
2063
- }
2064
- }
2065
- }
2066
- }
2061
+ load (arr) {
2062
+ // reset the cache
2063
+ this.reset();
2064
+
2065
+ const now = Date.now();
2066
+ // A previous serialized cache has the most recent items first
2067
+ for (let l = arr.length - 1; l >= 0; l--) {
2068
+ const hit = arr[l];
2069
+ const expiresAt = hit.e || 0;
2070
+ if (expiresAt === 0)
2071
+ // the item was created without expiration in a non aged cache
2072
+ this.set(hit.k, hit.v);
2073
+ else {
2074
+ const maxAge = expiresAt - now;
2075
+ // dont add already expired items
2076
+ if (maxAge > 0) {
2077
+ this.set(hit.k, hit.v, maxAge);
2078
+ }
2079
+ }
2080
+ }
2081
+ }
2067
2082
 
2068
- prune () {
2069
- this[CACHE].forEach((value, key) => get(this, key, false));
2070
- }
2071
- }
2083
+ prune () {
2084
+ this[CACHE].forEach((value, key) => get(this, key, false));
2085
+ }
2086
+ }
2072
2087
 
2073
- const get = (self, key, doUse) => {
2074
- const node = self[CACHE].get(key);
2075
- if (node) {
2076
- const hit = node.value;
2077
- if (isStale(self, hit)) {
2078
- del(self, node);
2079
- if (!self[ALLOW_STALE])
2080
- return undefined
2081
- } else {
2082
- if (doUse) {
2083
- if (self[UPDATE_AGE_ON_GET])
2084
- node.value.now = Date.now();
2085
- self[LRU_LIST].unshiftNode(node);
2086
- }
2087
- }
2088
- return hit.value
2089
- }
2090
- };
2088
+ const get = (self, key, doUse) => {
2089
+ const node = self[CACHE].get(key);
2090
+ if (node) {
2091
+ const hit = node.value;
2092
+ if (isStale(self, hit)) {
2093
+ del(self, node);
2094
+ if (!self[ALLOW_STALE])
2095
+ return undefined
2096
+ } else {
2097
+ if (doUse) {
2098
+ if (self[UPDATE_AGE_ON_GET])
2099
+ node.value.now = Date.now();
2100
+ self[LRU_LIST].unshiftNode(node);
2101
+ }
2102
+ }
2103
+ return hit.value
2104
+ }
2105
+ };
2091
2106
 
2092
- const isStale = (self, hit) => {
2093
- if (!hit || (!hit.maxAge && !self[MAX_AGE]))
2094
- return false
2107
+ const isStale = (self, hit) => {
2108
+ if (!hit || (!hit.maxAge && !self[MAX_AGE]))
2109
+ return false
2095
2110
 
2096
- const diff = Date.now() - hit.now;
2097
- return hit.maxAge ? diff > hit.maxAge
2098
- : self[MAX_AGE] && (diff > self[MAX_AGE])
2099
- };
2111
+ const diff = Date.now() - hit.now;
2112
+ return hit.maxAge ? diff > hit.maxAge
2113
+ : self[MAX_AGE] && (diff > self[MAX_AGE])
2114
+ };
2100
2115
 
2101
- const trim = self => {
2102
- if (self[LENGTH] > self[MAX]) {
2103
- for (let walker = self[LRU_LIST].tail;
2104
- self[LENGTH] > self[MAX] && walker !== null;) {
2105
- // We know that we're about to delete this one, and also
2106
- // what the next least recently used key will be, so just
2107
- // go ahead and set it now.
2108
- const prev = walker.prev;
2109
- del(self, walker);
2110
- walker = prev;
2111
- }
2112
- }
2113
- };
2116
+ const trim = self => {
2117
+ if (self[LENGTH] > self[MAX]) {
2118
+ for (let walker = self[LRU_LIST].tail;
2119
+ self[LENGTH] > self[MAX] && walker !== null;) {
2120
+ // We know that we're about to delete this one, and also
2121
+ // what the next least recently used key will be, so just
2122
+ // go ahead and set it now.
2123
+ const prev = walker.prev;
2124
+ del(self, walker);
2125
+ walker = prev;
2126
+ }
2127
+ }
2128
+ };
2114
2129
 
2115
- const del = (self, node) => {
2116
- if (node) {
2117
- const hit = node.value;
2118
- if (self[DISPOSE])
2119
- self[DISPOSE](hit.key, hit.value);
2130
+ const del = (self, node) => {
2131
+ if (node) {
2132
+ const hit = node.value;
2133
+ if (self[DISPOSE])
2134
+ self[DISPOSE](hit.key, hit.value);
2120
2135
 
2121
- self[LENGTH] -= hit.length;
2122
- self[CACHE].delete(hit.key);
2123
- self[LRU_LIST].removeNode(node);
2124
- }
2125
- };
2136
+ self[LENGTH] -= hit.length;
2137
+ self[CACHE].delete(hit.key);
2138
+ self[LRU_LIST].removeNode(node);
2139
+ }
2140
+ };
2126
2141
 
2127
- class Entry {
2128
- constructor (key, value, length, now, maxAge) {
2129
- this.key = key;
2130
- this.value = value;
2131
- this.length = length;
2132
- this.now = now;
2133
- this.maxAge = maxAge || 0;
2134
- }
2135
- }
2142
+ class Entry {
2143
+ constructor (key, value, length, now, maxAge) {
2144
+ this.key = key;
2145
+ this.value = value;
2146
+ this.length = length;
2147
+ this.now = now;
2148
+ this.maxAge = maxAge || 0;
2149
+ }
2150
+ }
2136
2151
 
2137
- const forEachStep = (self, fn, node, thisp) => {
2138
- let hit = node.value;
2139
- if (isStale(self, hit)) {
2140
- del(self, node);
2141
- if (!self[ALLOW_STALE])
2142
- hit = undefined;
2143
- }
2144
- if (hit)
2145
- fn.call(thisp, hit.value, hit.key, self);
2146
- };
2152
+ const forEachStep = (self, fn, node, thisp) => {
2153
+ let hit = node.value;
2154
+ if (isStale(self, hit)) {
2155
+ del(self, node);
2156
+ if (!self[ALLOW_STALE])
2157
+ hit = undefined;
2158
+ }
2159
+ if (hit)
2160
+ fn.call(thisp, hit.value, hit.key, self);
2161
+ };
2147
2162
 
2148
- var lruCache = LRUCache;
2163
+ lruCache = LRUCache;
2164
+ return lruCache;
2165
+ }
2149
2166
 
2150
2167
  var range;
2151
2168
  var hasRequiredRange;
@@ -2353,7 +2370,7 @@ function requireRange () {
2353
2370
 
2354
2371
  range = Range;
2355
2372
 
2356
- const LRU = lruCache;
2373
+ const LRU = requireLruCache();
2357
2374
  const cache = new LRU({ max: 1000 });
2358
2375
 
2359
2376
  const parseOptions = parseOptions_1;
@@ -3671,7 +3688,8 @@ class Transaction extends Protocol {
3671
3688
  await globalThis.transactionPoolStore.put(hash, message.encoded);
3672
3689
  // debug(`Added ${hash} to the transaction pool`)
3673
3690
  peernet.publish('add-transaction', message.encoded);
3674
- return { hash, data, fee: await calculateFee(message.decoded), wait, message };
3691
+ const fee = await calculateFee(message.decoded);
3692
+ return { hash, data, fee, wait, message };
3675
3693
  }
3676
3694
  catch (error) {
3677
3695
  console.log('remo');
@@ -3876,8 +3894,11 @@ class Machine {
3876
3894
  break;
3877
3895
  }
3878
3896
  case 'debug': {
3879
- for (const message of data.messages)
3880
- globalThis.debug(message);
3897
+ globalThis.debug(data.message);
3898
+ break;
3899
+ }
3900
+ case 'error': {
3901
+ console.error(data.message);
3881
3902
  break;
3882
3903
  }
3883
3904
  case 'machine-ready': {
@@ -4298,7 +4319,7 @@ class State extends Contract {
4298
4319
  try {
4299
4320
  await this.resolveBlocks();
4300
4321
  this.#machine = await new Machine(this.#blocks);
4301
- await this.#loadBlocks(this.#blocks);
4322
+ // await this.#loadBlocks(this.#blocks)
4302
4323
  }
4303
4324
  catch (error) {
4304
4325
  if (isResolveError(error)) {
@@ -4737,6 +4758,13 @@ class Chain extends VersionControl {
4737
4758
  this.#participants = [];
4738
4759
  this.#participating = false;
4739
4760
  this.#jail = [];
4761
+ this.#addTransaction = async (message) => {
4762
+ const transaction = new TransactionMessage(message);
4763
+ const hash = await transaction.hash();
4764
+ if (await transactionPool.has(hash))
4765
+ await transactionPool.delete(hash);
4766
+ console.log(transaction);
4767
+ };
4740
4768
  // @ts-ignore
4741
4769
  return this.#init();
4742
4770
  }
@@ -4840,9 +4868,7 @@ class Chain extends VersionControl {
4840
4868
  }, validatorInfo.timeout);
4841
4869
  this.#jail.push(validatorInfo.address);
4842
4870
  }
4843
- #addTransaction(message) {
4844
- console.log({ message });
4845
- }
4871
+ #addTransaction;
4846
4872
  async #prepareRequest(request) {
4847
4873
  let node = await new globalThis.peernet.protos['peernet-request']({ request });
4848
4874
  return globalThis.peernet.prepareMessage(node);
@@ -4867,7 +4893,6 @@ class Chain extends VersionControl {
4867
4893
  }
4868
4894
  async #peerConnected(peerId) {
4869
4895
  const peer = peernet.getConnection(peerId);
4870
- console.log({ peer });
4871
4896
  // todo handle version changes
4872
4897
  // for now just do nothing if version doesn't match
4873
4898
  console.log(`${peer.version}, ${this.version}`);