Skip to content

Commit e9ec2f7

Browse files
committed
1 parent faf9eff commit e9ec2f7

File tree

9 files changed

+95
-73
lines changed

9 files changed

+95
-73
lines changed

DEPENDENCIES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ graph LR;
441441
libnpmversion-->require-inject;
442442
libnpmversion-->semver;
443443
libnpmversion-->tap;
444+
lru-cache-->semver;
444445
lru-cache-->yallist;
445446
make-fetch-happen-->cacache;
446447
make-fetch-happen-->http-cache-semantics;

node_modules/lru-cache/dist/cjs/index.min.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

node_modules/lru-cache/dist/cjs/index.js renamed to node_modules/lru-cache/dist/commonjs/index.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,9 @@ class LRUCache {
435435
if (ttls[index]) {
436436
const ttl = ttls[index];
437437
const start = starts[index];
438+
/* c8 ignore next */
439+
if (!ttl || !start)
440+
return;
438441
status.ttl = ttl;
439442
status.start = start;
440443
status.now = cachedNow || getNow();
@@ -466,16 +469,16 @@ class LRUCache {
466469
}
467470
const ttl = ttls[index];
468471
const start = starts[index];
469-
if (ttl === 0 || start === 0) {
472+
if (!ttl || !start) {
470473
return Infinity;
471474
}
472475
const age = (cachedNow || getNow()) - start;
473476
return ttl - age;
474477
};
475478
this.#isStale = index => {
476-
return (ttls[index] !== 0 &&
477-
starts[index] !== 0 &&
478-
(cachedNow || getNow()) - starts[index] > ttls[index]);
479+
const s = starts[index];
480+
const t = ttls[index];
481+
return !!t && !!s && (cachedNow || getNow()) - s > t;
479482
};
480483
}
481484
// conditionally set private methods related to TTL
@@ -999,12 +1002,13 @@ class LRUCache {
9991002
peek(k, peekOptions = {}) {
10001003
const { allowStale = this.allowStale } = peekOptions;
10011004
const index = this.#keyMap.get(k);
1002-
if (index !== undefined &&
1003-
(allowStale || !this.#isStale(index))) {
1004-
const v = this.#valList[index];
1005-
// either stale and allowed, or forcing a refresh of non-stale value
1006-
return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
1005+
if (index === undefined ||
1006+
(!allowStale && this.#isStale(index))) {
1007+
return;
10071008
}
1009+
const v = this.#valList[index];
1010+
// either stale and allowed, or forcing a refresh of non-stale value
1011+
return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
10081012
}
10091013
#backgroundFetch(k, index, options, context) {
10101014
const v = index === undefined ? undefined : this.#valList[index];
@@ -1340,8 +1344,10 @@ class LRUCache {
13401344
this.#head = this.#next[index];
13411345
}
13421346
else {
1343-
this.#next[this.#prev[index]] = this.#next[index];
1344-
this.#prev[this.#next[index]] = this.#prev[index];
1347+
const pi = this.#prev[index];
1348+
this.#next[pi] = this.#next[index];
1349+
const ni = this.#next[index];
1350+
this.#prev[ni] = this.#prev[index];
13451351
}
13461352
this.#size--;
13471353
this.#free.push(index);

node_modules/lru-cache/dist/mjs/index.js renamed to node_modules/lru-cache/dist/esm/index.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ export class LRUCache {
432432
if (ttls[index]) {
433433
const ttl = ttls[index];
434434
const start = starts[index];
435+
/* c8 ignore next */
436+
if (!ttl || !start)
437+
return;
435438
status.ttl = ttl;
436439
status.start = start;
437440
status.now = cachedNow || getNow();
@@ -463,16 +466,16 @@ export class LRUCache {
463466
}
464467
const ttl = ttls[index];
465468
const start = starts[index];
466-
if (ttl === 0 || start === 0) {
469+
if (!ttl || !start) {
467470
return Infinity;
468471
}
469472
const age = (cachedNow || getNow()) - start;
470473
return ttl - age;
471474
};
472475
this.#isStale = index => {
473-
return (ttls[index] !== 0 &&
474-
starts[index] !== 0 &&
475-
(cachedNow || getNow()) - starts[index] > ttls[index]);
476+
const s = starts[index];
477+
const t = ttls[index];
478+
return !!t && !!s && (cachedNow || getNow()) - s > t;
476479
};
477480
}
478481
// conditionally set private methods related to TTL
@@ -996,12 +999,13 @@ export class LRUCache {
996999
peek(k, peekOptions = {}) {
9971000
const { allowStale = this.allowStale } = peekOptions;
9981001
const index = this.#keyMap.get(k);
999-
if (index !== undefined &&
1000-
(allowStale || !this.#isStale(index))) {
1001-
const v = this.#valList[index];
1002-
// either stale and allowed, or forcing a refresh of non-stale value
1003-
return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
1002+
if (index === undefined ||
1003+
(!allowStale && this.#isStale(index))) {
1004+
return;
10041005
}
1006+
const v = this.#valList[index];
1007+
// either stale and allowed, or forcing a refresh of non-stale value
1008+
return this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
10051009
}
10061010
#backgroundFetch(k, index, options, context) {
10071011
const v = index === undefined ? undefined : this.#valList[index];
@@ -1337,8 +1341,10 @@ export class LRUCache {
13371341
this.#head = this.#next[index];
13381342
}
13391343
else {
1340-
this.#next[this.#prev[index]] = this.#next[index];
1341-
this.#prev[this.#next[index]] = this.#prev[index];
1344+
const pi = this.#prev[index];
1345+
this.#next[pi] = this.#next[index];
1346+
const ni = this.#next[index];
1347+
this.#prev[ni] = this.#prev[index];
13421348
}
13431349
this.#size--;
13441350
this.#free.push(index);

node_modules/lru-cache/dist/mjs/index.min.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

node_modules/lru-cache/package.json

Lines changed: 54 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "lru-cache",
33
"description": "A cache object that deletes the least-recently-used items.",
4-
"version": "10.0.1",
4+
"version": "10.0.2",
55
"author": "Isaac Z. Schlueter <[email protected]>",
66
"keywords": [
77
"mru",
@@ -11,67 +11,57 @@
1111
"sideEffects": false,
1212
"scripts": {
1313
"build": "npm run prepare",
14-
"preprepare": "rm -rf dist",
15-
"prepare": "tsc -p tsconfig.json && tsc -p tsconfig-esm.json",
14+
"prepare": "tshy",
1615
"postprepare": "bash fixup.sh",
1716
"pretest": "npm run prepare",
1817
"presnap": "npm run prepare",
19-
"test": "c8 tap",
20-
"snap": "c8 tap",
18+
"test": "tap",
19+
"snap": "tap",
2120
"preversion": "npm test",
2221
"postversion": "npm publish",
2322
"prepublishOnly": "git push origin --follow-tags",
2423
"format": "prettier --write .",
25-
"typedoc": "typedoc --tsconfig tsconfig-esm.json ./src/*.ts",
24+
"typedoc": "typedoc --tsconfig ./.tshy/esm.json ./src/*.ts",
2625
"benchmark-results-typedoc": "bash scripts/benchmark-results-typedoc.sh",
2726
"prebenchmark": "npm run prepare",
2827
"benchmark": "make -C benchmark",
2928
"preprofile": "npm run prepare",
3029
"profile": "make -C benchmark profile"
3130
},
32-
"main": "./dist/cjs/index.js",
33-
"module": "./dist/mjs/index.js",
34-
"exports": {
35-
"./min": {
36-
"import": {
37-
"types": "./dist/mjs/index.d.ts",
38-
"default": "./dist/mjs/index.min.js"
39-
},
40-
"require": {
41-
"types": "./dist/cjs/index.d.ts",
42-
"default": "./dist/cjs/index.min.js"
43-
}
44-
},
45-
".": {
46-
"import": {
47-
"types": "./dist/mjs/index.d.ts",
48-
"default": "./dist/mjs/index.js"
49-
},
50-
"require": {
51-
"types": "./dist/cjs/index.d.ts",
52-
"default": "./dist/cjs/index.js"
31+
"main": "./dist/commonjs/index.js",
32+
"types": "./dist/commonjs/index.d.ts",
33+
"tshy": {
34+
"exports": {
35+
".": "./src/index.ts",
36+
"./min": {
37+
"import": {
38+
"types": "./dist/mjs/index.d.ts",
39+
"default": "./dist/mjs/index.min.js"
40+
},
41+
"require": {
42+
"types": "./dist/commonjs/index.d.ts",
43+
"default": "./dist/commonjs/index.min.js"
44+
}
5345
}
5446
}
5547
},
5648
"repository": "git://github.com/isaacs/node-lru-cache.git",
5749
"devDependencies": {
58-
"@size-limit/preset-small-lib": "^7.0.8",
50+
"@tapjs/clock": "^1.1.16",
5951
"@types/node": "^20.2.5",
6052
"@types/tap": "^15.0.6",
6153
"benchmark": "^2.1.4",
62-
"c8": "^7.11.2",
63-
"clock-mock": "^1.0.6",
54+
"clock-mock": "^2.0.2",
6455
"esbuild": "^0.17.11",
6556
"eslint-config-prettier": "^8.5.0",
6657
"marked": "^4.2.12",
6758
"mkdirp": "^2.1.5",
6859
"prettier": "^2.6.2",
69-
"size-limit": "^7.0.8",
70-
"tap": "^16.3.4",
71-
"ts-node": "^10.9.1",
60+
"tap": "^18.5.7",
61+
"tshy": "^1.8.0",
7262
"tslib": "^2.4.0",
73-
"typedoc": "^0.24.6",
74-
"typescript": "^5.0.4"
63+
"typedoc": "^0.25.3",
64+
"typescript": "^5.2.2"
7565
},
7666
"license": "ISC",
7767
"files": [
@@ -92,17 +82,37 @@
9282
"endOfLine": "lf"
9383
},
9484
"tap": {
95-
"coverage": false,
9685
"node-arg": [
97-
"--expose-gc",
98-
"-r",
99-
"ts-node/register"
86+
"--expose-gc"
10087
],
101-
"ts": false
88+
"plugin": [
89+
"@tapjs/clock"
90+
]
10291
},
103-
"size-limit": [
104-
{
105-
"path": "./dist/mjs/index.js"
92+
"exports": {
93+
".": {
94+
"import": {
95+
"types": "./dist/esm/index.d.ts",
96+
"default": "./dist/esm/index.js"
97+
},
98+
"require": {
99+
"types": "./dist/commonjs/index.d.ts",
100+
"default": "./dist/commonjs/index.js"
101+
}
102+
},
103+
"./min": {
104+
"import": {
105+
"types": "./dist/mjs/index.d.ts",
106+
"default": "./dist/mjs/index.min.js"
107+
},
108+
"require": {
109+
"types": "./dist/commonjs/index.d.ts",
110+
"default": "./dist/commonjs/index.min.js"
111+
}
106112
}
107-
]
113+
},
114+
"type": "module",
115+
"dependencies": {
116+
"semver": "^7.3.5"
117+
}
108118
}

package-lock.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10200,10 +10200,13 @@
1020010200
}
1020110201
},
1020210202
"node_modules/lru-cache": {
10203-
"version": "10.0.1",
10204-
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.1.tgz",
10205-
"integrity": "sha512-IJ4uwUTi2qCccrioU6g9g/5rvvVl13bsdczUUcqbciD9iLr095yj8DQKdObriEvuNSx325N1rV1O0sJFszx75g==",
10203+
"version": "10.0.2",
10204+
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.2.tgz",
10205+
"integrity": "sha512-Yj9mA8fPiVgOUpByoTZO5pNrcl5Yk37FcSHsUINpAsaBIEZIuqcCclDZJCVxqQShDsmYX8QG63svJiTbOATZwg==",
1020610206
"inBundle": true,
10207+
"dependencies": {
10208+
"semver": "^7.3.5"
10209+
},
1020710210
"engines": {
1020810211
"node": "14 || >=16.14"
1020910212
}

0 commit comments

Comments
 (0)