@leofcoin/chain 1.7.29 → 1.7.30
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/chain.js +42 -34
- package/package.json +1 -1
package/exports/browser/chain.js
CHANGED
|
@@ -1419,46 +1419,54 @@ const coerce$1 = (version, options) => {
|
|
|
1419
1419
|
};
|
|
1420
1420
|
var coerce_1 = coerce$1;
|
|
1421
1421
|
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1422
|
+
var lrucache;
|
|
1423
|
+
var hasRequiredLrucache;
|
|
1424
|
+
|
|
1425
|
+
function requireLrucache () {
|
|
1426
|
+
if (hasRequiredLrucache) return lrucache;
|
|
1427
|
+
hasRequiredLrucache = 1;
|
|
1428
|
+
class LRUCache {
|
|
1429
|
+
constructor () {
|
|
1430
|
+
this.max = 1000;
|
|
1431
|
+
this.map = new Map();
|
|
1432
|
+
}
|
|
1427
1433
|
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1434
|
+
get (key) {
|
|
1435
|
+
const value = this.map.get(key);
|
|
1436
|
+
if (value === undefined) {
|
|
1437
|
+
return undefined
|
|
1438
|
+
} else {
|
|
1439
|
+
// Remove the key from the map and add it to the end
|
|
1440
|
+
this.map.delete(key);
|
|
1441
|
+
this.map.set(key, value);
|
|
1442
|
+
return value
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1439
1445
|
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1446
|
+
delete (key) {
|
|
1447
|
+
return this.map.delete(key)
|
|
1448
|
+
}
|
|
1443
1449
|
|
|
1444
|
-
|
|
1445
|
-
|
|
1450
|
+
set (key, value) {
|
|
1451
|
+
const deleted = this.delete(key);
|
|
1446
1452
|
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
+
if (!deleted && value !== undefined) {
|
|
1454
|
+
// If cache is full, delete the least recently used item
|
|
1455
|
+
if (this.map.size >= this.max) {
|
|
1456
|
+
const firstKey = this.map.keys().next().value;
|
|
1457
|
+
this.delete(firstKey);
|
|
1458
|
+
}
|
|
1453
1459
|
|
|
1454
|
-
|
|
1455
|
-
|
|
1460
|
+
this.map.set(key, value);
|
|
1461
|
+
}
|
|
1456
1462
|
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
}
|
|
1463
|
+
return this
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1460
1466
|
|
|
1461
|
-
|
|
1467
|
+
lrucache = LRUCache;
|
|
1468
|
+
return lrucache;
|
|
1469
|
+
}
|
|
1462
1470
|
|
|
1463
1471
|
var range;
|
|
1464
1472
|
var hasRequiredRange;
|
|
@@ -1680,7 +1688,7 @@ function requireRange () {
|
|
|
1680
1688
|
|
|
1681
1689
|
range = Range;
|
|
1682
1690
|
|
|
1683
|
-
const LRU =
|
|
1691
|
+
const LRU = requireLrucache();
|
|
1684
1692
|
const cache = new LRU();
|
|
1685
1693
|
|
|
1686
1694
|
const parseOptions = parseOptions_1;
|