+71
-13
lines changedFilter options
+71
-13
lines changed Original file line number Diff line number Diff line change
@@ -441,7 +441,6 @@ graph LR;
441
441
libnpmversion-->require-inject;
442
442
libnpmversion-->semver;
443
443
libnpmversion-->tap;
444
-
lru-cache-->semver;
445
444
lru-cache-->yallist;
446
445
make-fetch-happen-->cacache;
447
446
make-fetch-happen-->http-cache-semantics;
Original file line number Diff line number Diff line change
@@ -736,6 +736,37 @@ class LRUCache {
736
736
}
737
737
return deleted;
738
738
}
739
+
/**
740
+
* Get the extended info about a given entry, to get its value, size, and
741
+
* TTL info simultaneously. Like {@link LRUCache#dump}, but just for a
742
+
* single key. Always returns stale values, if their info is found in the
743
+
* cache, so be sure to check for expired TTLs if relevant.
744
+
*/
745
+
info(key) {
746
+
const i = this.#keyMap.get(key);
747
+
if (i === undefined)
748
+
return undefined;
749
+
const v = this.#valList[i];
750
+
const value = this.#isBackgroundFetch(v)
751
+
? v.__staleWhileFetching
752
+
: v;
753
+
if (value === undefined)
754
+
return undefined;
755
+
const entry = { value };
756
+
if (this.#ttls && this.#starts) {
757
+
const ttl = this.#ttls[i];
758
+
const start = this.#starts[i];
759
+
if (ttl && start) {
760
+
const remain = ttl - (perf.now() - start);
761
+
entry.ttl = remain;
762
+
entry.start = Date.now();
763
+
}
764
+
}
765
+
if (this.#sizes) {
766
+
entry.size = this.#sizes[i];
767
+
}
768
+
return entry;
769
+
}
739
770
/**
740
771
* Return an array of [key, {@link LRUCache.Entry}] tuples which can be
741
772
* passed to cache.load()
Original file line number Diff line number Diff line change
@@ -733,6 +733,37 @@ export class LRUCache {
733
733
}
734
734
return deleted;
735
735
}
736
+
/**
737
+
* Get the extended info about a given entry, to get its value, size, and
738
+
* TTL info simultaneously. Like {@link LRUCache#dump}, but just for a
739
+
* single key. Always returns stale values, if their info is found in the
740
+
* cache, so be sure to check for expired TTLs if relevant.
741
+
*/
742
+
info(key) {
743
+
const i = this.#keyMap.get(key);
744
+
if (i === undefined)
745
+
return undefined;
746
+
const v = this.#valList[i];
747
+
const value = this.#isBackgroundFetch(v)
748
+
? v.__staleWhileFetching
749
+
: v;
750
+
if (value === undefined)
751
+
return undefined;
752
+
const entry = { value };
753
+
if (this.#ttls && this.#starts) {
754
+
const ttl = this.#ttls[i];
755
+
const start = this.#starts[i];
756
+
if (ttl && start) {
757
+
const remain = ttl - (perf.now() - start);
758
+
entry.ttl = remain;
759
+
entry.start = Date.now();
760
+
}
761
+
}
762
+
if (this.#sizes) {
763
+
entry.size = this.#sizes[i];
764
+
}
765
+
return entry;
766
+
}
736
767
/**
737
768
* Return an array of [key, {@link LRUCache.Entry}] tuples which can be
738
769
* passed to cache.load()
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
1
1
{
2
2
"name": "lru-cache",
3
3
"description": "A cache object that deletes the least-recently-used items.",
4
-
"version": "10.0.2",
4
+
"version": "10.1.0",
5
5
"author": "Isaac Z. Schlueter <i@izs.me>",
6
6
"keywords": [
7
7
"mru",
@@ -45,7 +45,10 @@
45
45
}
46
46
}
47
47
},
48
-
"repository": "git://github.com/isaacs/node-lru-cache.git",
48
+
"repository": {
49
+
"type": "git",
50
+
"url": "git://github.com/isaacs/node-lru-cache.git"
51
+
},
49
52
"devDependencies": {
50
53
"@tapjs/clock": "^1.1.16",
51
54
"@types/node": "^20.2.5",
@@ -111,8 +114,5 @@
111
114
}
112
115
}
113
116
},
114
-
"type": "module",
115
-
"dependencies": {
116
-
"semver": "^7.3.5"
117
-
}
117
+
"type": "module"
118
118
}
Original file line number Diff line number Diff line change
@@ -10248,13 +10248,10 @@
10248
10248
}
10249
10249
},
10250
10250
"node_modules/lru-cache": {
10251
-
"version": "10.0.2",
10252
-
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.2.tgz",
10253
-
"integrity": "sha512-Yj9mA8fPiVgOUpByoTZO5pNrcl5Yk37FcSHsUINpAsaBIEZIuqcCclDZJCVxqQShDsmYX8QG63svJiTbOATZwg==",
10251
+
"version": "10.1.0",
10252
+
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.1.0.tgz",
10253
+
"integrity": "sha512-/1clY/ui8CzjKFyjdvwPWJUYKiFVXG2I2cY0ssG7h4+hwk+XOIX7ZSG9Q7TW8TW3Kp3BUSqgFWBLgL4PJ+Blag==",
10254
10254
"inBundle": true,
10255
-
"dependencies": {
10256
-
"semver": "^7.3.5"
10257
-
},
10258
10255
"engines": {
10259
10256
"node": "14 || >=16.14"
10260
10257
}
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4