Skip to content

Commit 8dae069

Browse files
committed
Upgrade lru-cache dependency
1 parent 2c1fa1b commit 8dae069

File tree

3 files changed

+16
-28
lines changed

3 files changed

+16
-28
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@
433433
"@types/glob": "^7.1.4",
434434
"@types/js-yaml": "^4.0.5",
435435
"@types/lodash-es": "^4.17.3",
436-
"@types/lru-cache": "^4.1.2",
436+
"@types/lru-cache": "^7.6.1",
437437
"@types/mocha": "^9.0.0",
438438
"@types/node": "^17.0.23",
439439
"@types/request-promise-native": "^1.0.17",
@@ -465,7 +465,7 @@
465465
"extend": ">=3.0.2",
466466
"js-yaml": "^4.1.0",
467467
"lodash-es": "^4.17.21",
468-
"lru-cache": "^4.1.5",
468+
"lru-cache": "^7.7.3",
469469
"request": "^2.88.2",
470470
"request-promise-native": "^1.0.8",
471471
"ts-pattern": "^4.0.1",

src/commands/importIdentifier.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as cheerio from 'cheerio';
22
import * as yaml from 'js-yaml';
33
import escapeRegExp from 'lodash-es/escapeRegExp';
4-
import * as LRU from 'lru-cache';
4+
import * as LRUCache from 'lru-cache';
55
import * as request from 'request-promise-native';
66
import * as vscode from 'vscode';
77
import { CommandNames } from './constants';
@@ -14,7 +14,7 @@ const askHoogle = async (variable: string): Promise<any> => {
1414
};
1515

1616
const withCache =
17-
<T, U>(theCache: LRU.Cache<T, U>, f: (a: T) => U) =>
17+
<T, U>(theCache: LRUCache<T, U>, f: (a: T) => U) =>
1818
(a: T) => {
1919
const maybeB = theCache.get(a);
2020
if (maybeB) {
@@ -26,10 +26,11 @@ const withCache =
2626
}
2727
};
2828

29-
const cache: LRU.Cache<string, Promise<any>> = LRU({
29+
const cache: LRUCache<string, Promise<any>> = new LRUCache({
3030
// 1 MB
3131
max: 1000 * 1000,
32-
length: (r: any) => JSON.stringify(r).length,
32+
maxSize: 1000 * 1000,
33+
sizeCalculation: (r: any) => JSON.stringify(r).length,
3334
});
3435

3536
const askHoogleCached = withCache(cache, askHoogle);

yarn.lock

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@
146146
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.181.tgz#d1d3740c379fda17ab175165ba04e2d03389385d"
147147
integrity sha512-n3tyKthHJbkiWhDZs3DkhkCzt2MexYHXlX0td5iMplyfwketaOeKboEVBqzceH7juqvEg3q5oUoBFxSLu7zFag==
148148

149-
"@types/lru-cache@^4.1.2":
150-
version "4.1.3"
151-
resolved "https://registry.yarnpkg.com/@types/lru-cache/-/lru-cache-4.1.3.tgz#ec5eb6dd818b7a06336cfb7368723164b195f818"
152-
integrity sha512-QjCOmf5kYwekcsfEKhcEHMK8/SvgnneuSDXFERBuC/DPca2KJIO/gpChTsVb35BoWLBpEAJWz1GFVEArSdtKtw==
149+
"@types/lru-cache@^7.6.1":
150+
version "7.6.1"
151+
resolved "https://registry.yarnpkg.com/@types/lru-cache/-/lru-cache-7.6.1.tgz#99809260ef1e870b8ef2ab3a625784a33cec5ba9"
152+
integrity sha512-69x+Dhrm2aShFkTqUuPgUXbKYwvq4FH/DVeeQH7MBfTjbKjPX51NGLERxVV1vf33N71dzLvXCko4OLqRvsq53Q==
153153

154154
"@types/minimatch@*", "@types/minimatch@^3.0.3":
155155
version "3.0.5"
@@ -1797,21 +1797,18 @@ [email protected]:
17971797
chalk "^4.1.0"
17981798
is-unicode-supported "^0.1.0"
17991799

1800-
lru-cache@^4.1.5:
1801-
version "4.1.5"
1802-
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd"
1803-
integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==
1804-
dependencies:
1805-
pseudomap "^1.0.2"
1806-
yallist "^2.1.2"
1807-
18081800
lru-cache@^6.0.0:
18091801
version "6.0.0"
18101802
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
18111803
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==
18121804
dependencies:
18131805
yallist "^4.0.0"
18141806

1807+
lru-cache@^7.7.3:
1808+
version "7.7.3"
1809+
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-7.7.3.tgz#98cd19eef89ce6a4a3c4502c17c833888677c252"
1810+
integrity sha512-WY9wjJNQt9+PZilnLbuFKM+SwDull9+6IAguOrarOMoOHTcJ9GnXSO11+Gw6c7xtDkBkthR57OZMtZKYr+1CEw==
1811+
18151812
merge-stream@^2.0.0:
18161813
version "2.0.0"
18171814
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
@@ -2135,11 +2132,6 @@ process-nextick-args@~2.0.0:
21352132
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
21362133
integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==
21372134

2138-
pseudomap@^1.0.2:
2139-
version "1.0.2"
2140-
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
2141-
integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM=
2142-
21432135
psl@^1.1.28:
21442136
version "1.8.0"
21452137
resolved "https://registry.yarnpkg.com/psl/-/psl-1.8.0.tgz#9326f8bcfb013adcc005fdff056acce020e51c24"
@@ -2826,11 +2818,6 @@ y18n@^5.0.5:
28262818
resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55"
28272819
integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==
28282820

2829-
yallist@^2.1.2:
2830-
version "2.1.2"
2831-
resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"
2832-
integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=
2833-
28342821
yallist@^4.0.0:
28352822
version "4.0.0"
28362823
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"

0 commit comments

Comments
 (0)