Skip to content

Commit 4ea1368

Browse files
43081jraineorshine
andauthored
replace mem with fast-memoize (#919)
* replace mem with fast-memoize * lint Co-authored-by: Raine Revere <[email protected]>
1 parent 45eb890 commit 4ea1368

File tree

3 files changed

+14
-73
lines changed

3 files changed

+14
-73
lines changed

lib/package-managers/npm.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const fs = require('fs')
66
const semver = require('semver')
77
const spawn = require('spawn-please')
88
const pacote = require('pacote')
9-
const mem = require('mem')
9+
const memoize = require('fast-memoize')
1010
const libnpmconfig = require('libnpmconfig')
1111
const versionUtil = require('../version-util')
1212
const { print } = require('../logging')
@@ -148,10 +148,7 @@ async function viewMany(packageName, fields, currentVersion, { registry, timeout
148148
}
149149

150150
/** Memoize viewMany for --deep performance. */
151-
const viewManyMemoized = mem(viewMany, {
152-
cacheKey: ([packageName, fields, currentVersion]) =>
153-
`${packageName}|${fields.join('|')}|${currentVersion}`
154-
})
151+
const viewManyMemoized = memoize(viewMany)
155152

156153
/**
157154
* Returns true if the node engine requirement is satisfied or not specified for a given package version.

package-lock.json

Lines changed: 11 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"cint": "^8.2.1",
6060
"cli-table": "^0.3.6",
6161
"commander": "^6.2.1",
62+
"fast-memoize": "^2.5.2",
6263
"find-up": "5.0.0",
6364
"fp-and-or": "^0.1.3",
6465
"get-stdin": "^8.0.0",
@@ -68,7 +69,6 @@
6869
"jsonlines": "^0.1.1",
6970
"libnpmconfig": "^1.2.1",
7071
"lodash": "^4.17.21",
71-
"mem": "^8.1.1",
7272
"minimatch": "^3.0.4",
7373
"p-map": "^4.0.0",
7474
"pacote": "^11.3.4",

0 commit comments

Comments
 (0)