diff --git a/deps/npm/docs/content/commands/npm-ls.md b/deps/npm/docs/content/commands/npm-ls.md
index 8fa273e8ab1c35..139e6ec56e3f87 100644
--- a/deps/npm/docs/content/commands/npm-ls.md
+++ b/deps/npm/docs/content/commands/npm-ls.md
@@ -27,7 +27,7 @@ packages will *also* show the paths to the specified packages. For
example, running `npm ls promzard` in npm's source tree will show:
```bash
-npm@9.5.0 /path/to/npm
+npm@9.5.1 /path/to/npm
└─┬ init-package-json@0.0.4
└── promzard@0.1.5
```
diff --git a/deps/npm/docs/content/commands/npm.md b/deps/npm/docs/content/commands/npm.md
index abe229d5681939..6d6f5771e3b0c6 100644
--- a/deps/npm/docs/content/commands/npm.md
+++ b/deps/npm/docs/content/commands/npm.md
@@ -14,7 +14,7 @@ Note: This command is unaware of workspaces.
### Version
-9.5.0
+9.5.1
### Description
diff --git a/deps/npm/docs/content/configuring-npm/package-json.md b/deps/npm/docs/content/configuring-npm/package-json.md
index 0abaad2c1ff7f0..ac5a5740ed3bfd 100644
--- a/deps/npm/docs/content/configuring-npm/package-json.md
+++ b/deps/npm/docs/content/configuring-npm/package-json.md
@@ -120,7 +120,7 @@ SPDX license identifier for the license you're using, like this:
You can check [the full list of SPDX license
IDs](https://spdx.org/licenses/). Ideally you should pick one that is
-[OSI](https://opensource.org/licenses/alphabetical) approved.
+[OSI](https://opensource.org/licenses/) approved.
If your package is licensed under multiple common licenses, use an [SPDX
license expression syntax version 2.0
diff --git a/deps/npm/docs/output/commands/npm-ls.html b/deps/npm/docs/output/commands/npm-ls.html
index 8411b221adb082..26d3dce7718e76 100644
--- a/deps/npm/docs/output/commands/npm-ls.html
+++ b/deps/npm/docs/output/commands/npm-ls.html
@@ -160,7 +160,7 @@
Description
the results to only the paths to the packages named. Note that nested
packages will also show the paths to the specified packages. For
example, running npm ls promzard
in npm's source tree will show:
-npm@9.5.0 /path/to/npm
+npm@9.5.1 /path/to/npm
└─┬ init-package-json@0.0.4
└── promzard@0.1.5
diff --git a/deps/npm/docs/output/commands/npm.html b/deps/npm/docs/output/commands/npm.html
index f3678c6bf9393f..d16a1cec6c69e8 100644
--- a/deps/npm/docs/output/commands/npm.html
+++ b/deps/npm/docs/output/commands/npm.html
@@ -150,7 +150,7 @@ Table of contents
Note: This command is unaware of workspaces.
Version
-9.5.0
+9.5.1
Description
npm is the package manager for the Node JavaScript platform. It puts
modules in place so that node can find them, and manages dependency
diff --git a/deps/npm/docs/output/configuring-npm/package-json.html b/deps/npm/docs/output/configuring-npm/package-json.html
index 4ac57d2a393437..22255659969e8f 100644
--- a/deps/npm/docs/output/configuring-npm/package-json.html
+++ b/deps/npm/docs/output/configuring-npm/package-json.html
@@ -230,7 +230,7 @@
license
You can check the full list of SPDX license
IDs. Ideally you should pick one that is
-OSI approved.
+OSI approved.
If your package is licensed under multiple common licenses, use an SPDX
license expression syntax version 2.0
string, like this:
diff --git a/deps/npm/lib/commands/help.js b/deps/npm/lib/commands/help.js
index 3ab2c563198680..28f18e7edcef70 100644
--- a/deps/npm/lib/commands/help.js
+++ b/deps/npm/lib/commands/help.js
@@ -10,7 +10,7 @@ const BaseCommand = require('../base-command.js')
// Strips out the number from foo.7 or foo.7. or foo.7.tgz
// We don't currently compress our man pages but if we ever did this would
-// seemlessly continue supporting it
+// seamlessly continue supporting it
const manNumberRegex = /\.(\d+)(\.[^/\\]*)?$/
// Searches for the "npm-" prefix in page names, to prefer those.
const manNpmPrefixRegex = /\/npm-/
diff --git a/deps/npm/lib/commands/link.js b/deps/npm/lib/commands/link.js
index 5af2c7c269f8fb..6d8027f2b9cb68 100644
--- a/deps/npm/lib/commands/link.js
+++ b/deps/npm/lib/commands/link.js
@@ -52,7 +52,7 @@ class Link extends ArboristWorkspaceCmd {
{ code: 'ELINKGLOBAL' }
)
}
- // install-links is implicitely false when running `npm link`
+ // install-links is implicitly false when running `npm link`
this.npm.config.set('install-links', false)
// link with no args: symlink the folder to the global location
diff --git a/deps/npm/lib/utils/queryable.js b/deps/npm/lib/utils/queryable.js
index 6acc1758ceea70..5ddcf636e83836 100644
--- a/deps/npm/lib/utils/queryable.js
+++ b/deps/npm/lib/utils/queryable.js
@@ -4,7 +4,7 @@ const _append = Symbol('append')
const sqBracketsMatcher = str => str.match(/(.+)\[([^\]]+)\]\.?(.*)$/)
-// replaces any occurence of an empty-brackets (e.g: []) with a special
+// replaces any occurrence of an empty-brackets (e.g: []) with a special
// Symbol(append) to represent it, this is going to be useful for the setter
// method that will push values to the end of the array when finding these
const replaceAppendSymbols = str => {
@@ -29,7 +29,7 @@ const parseKeys = key => {
const preSqBracketPortion = index[1]
// we want to have a `new String` wrapper here in order to differentiate
- // between multiple occurences of the same string, e.g:
+ // between multiple occurrences of the same string, e.g:
// foo.bar[foo.bar] should split into { foo: { bar: { 'foo.bar': {} } }
/* eslint-disable-next-line no-new-wrappers */
const foundKey = new String(index[2])
@@ -41,7 +41,7 @@ const parseKeys = key => {
sqBracketItems.add(foundKey)
// returns an array that contains either dot-separate items (that will
- // be splitted appart during the next step OR the fully parsed keys
+ // be split apart during the next step OR the fully parsed keys
// read from square brackets, e.g:
// foo.bar[1.0.0].a.b -> ['foo.bar', '1.0.0', 'a.b']
return [
@@ -142,7 +142,7 @@ const setter = ({ data, key, value, force }) => {
const keys = parseKeys(key)
const setKeys = (_data, _key) => {
// handles array indexes, converting valid integers to numbers,
- // note that occurences of Symbol(append) will throw,
+ // note that occurrences of Symbol(append) will throw,
// so we just ignore these for now
let maybeIndex = Number.NaN
try {
diff --git a/deps/npm/lib/workspaces/update-workspaces.js b/deps/npm/lib/workspaces/update-workspaces.js
index 4cba1245ac2e57..d22abda7c5b0be 100644
--- a/deps/npm/lib/workspaces/update-workspaces.js
+++ b/deps/npm/lib/workspaces/update-workspaces.js
@@ -22,7 +22,7 @@ async function updateWorkspaces ({
? false
: config.get('save')
- // runs a minimalistic reify update, targetting only the workspaces
+ // runs a minimalistic reify update, targeting only the workspaces
// that had version updates and skipping fund/audit/save
const opts = {
...flatOptions,
diff --git a/deps/npm/man/man1/npm-ls.1 b/deps/npm/man/man1/npm-ls.1
index 3d12f7a42dfb47..ac59cba39a3f50 100644
--- a/deps/npm/man/man1/npm-ls.1
+++ b/deps/npm/man/man1/npm-ls.1
@@ -20,7 +20,7 @@ Positional arguments are \fBname@version-range\fR identifiers, which will limit
.P
.RS 2
.nf
-npm@9.5.0 /path/to/npm
+npm@9.5.1 /path/to/npm
└─┬ init-package-json@0.0.4
└── promzard@0.1.5
.fi
diff --git a/deps/npm/man/man1/npm.1 b/deps/npm/man/man1/npm.1
index 3e1b5acf5c0bfc..631f484d455b98 100644
--- a/deps/npm/man/man1/npm.1
+++ b/deps/npm/man/man1/npm.1
@@ -12,7 +12,7 @@ npm
Note: This command is unaware of workspaces.
.SS "Version"
.P
-9.5.0
+9.5.1
.SS "Description"
.P
npm is the package manager for the Node JavaScript platform. It puts modules in place so that node can find them, and manages dependency conflicts intelligently.
diff --git a/deps/npm/man/man5/npm-json.5 b/deps/npm/man/man5/npm-json.5
index ceafaf29104e66..8f7dd8fd5b73e6 100644
--- a/deps/npm/man/man5/npm-json.5
+++ b/deps/npm/man/man5/npm-json.5
@@ -93,7 +93,7 @@ If you're using a common license such as BSD-2-Clause or MIT, add a current SPDX
.fi
.RE
.P
-You can check \fBthe full list of SPDX license IDs\fR \fI\(lahttps://spdx.org/licenses/\(ra\fR. Ideally you should pick one that is \fBOSI\fR \fI\(lahttps://opensource.org/licenses/alphabetical\(ra\fR approved.
+You can check \fBthe full list of SPDX license IDs\fR \fI\(lahttps://spdx.org/licenses/\(ra\fR. Ideally you should pick one that is \fBOSI\fR \fI\(lahttps://opensource.org/licenses/\(ra\fR approved.
.P
If your package is licensed under multiple common licenses, use an \fBSPDX license expression syntax version 2.0 string\fR \fI\(lahttps://spdx.dev/specifications/\(ra\fR, like this:
.P
diff --git a/deps/npm/man/man5/package-json.5 b/deps/npm/man/man5/package-json.5
index ceafaf29104e66..8f7dd8fd5b73e6 100644
--- a/deps/npm/man/man5/package-json.5
+++ b/deps/npm/man/man5/package-json.5
@@ -93,7 +93,7 @@ If you're using a common license such as BSD-2-Clause or MIT, add a current SPDX
.fi
.RE
.P
-You can check \fBthe full list of SPDX license IDs\fR \fI\(lahttps://spdx.org/licenses/\(ra\fR. Ideally you should pick one that is \fBOSI\fR \fI\(lahttps://opensource.org/licenses/alphabetical\(ra\fR approved.
+You can check \fBthe full list of SPDX license IDs\fR \fI\(lahttps://spdx.org/licenses/\(ra\fR. Ideally you should pick one that is \fBOSI\fR \fI\(lahttps://opensource.org/licenses/\(ra\fR approved.
.P
If your package is licensed under multiple common licenses, use an \fBSPDX license expression syntax version 2.0 string\fR \fI\(lahttps://spdx.dev/specifications/\(ra\fR, like this:
.P
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js
index e8df69e328ce85..d502d5244bdc7e 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js
@@ -89,7 +89,6 @@ module.exports = cls => class Builder extends cls {
const {
depNodes,
linkNodes,
- storeNodes,
} = this[_retrieveNodesByType](nodes)
// build regular deps
@@ -100,10 +99,6 @@ module.exports = cls => class Builder extends cls {
this[_resetQueues]()
await this[_build](linkNodes, { type: 'links' })
}
- if (storeNodes.size) {
- this[_resetQueues]()
- await this[_build](storeNodes, { type: 'storelinks' })
- }
process.emit('timeEnd', 'build')
}
@@ -146,6 +141,12 @@ module.exports = cls => class Builder extends cls {
depNodes.add(node)
}
}
+ // Make sure that store linked nodes are processed last.
+ // We can't process store links separately or else lifecycle scripts on
+ // standard nodes might not have bin links yet.
+ for (const node of storeNodes) {
+ depNodes.add(node)
+ }
// deduplicates link nodes and their targets, avoids
// calling lifecycle scripts twice when running `npm rebuild`
@@ -162,7 +163,6 @@ module.exports = cls => class Builder extends cls {
return {
depNodes,
linkNodes,
- storeNodes,
}
}
@@ -330,10 +330,12 @@ module.exports = cls => class Builder extends cls {
devOptional,
package: pkg,
location,
+ isStoreLink,
} = node.target
// skip any that we know we'll be deleting
- if (this[_trashList].has(path)) {
+ // or storeLinks
+ if (this[_trashList].has(path) || isStoreLink) {
return
}
diff --git a/deps/npm/node_modules/@npmcli/arborist/package.json b/deps/npm/node_modules/@npmcli/arborist/package.json
index f27b1458d8d59c..aaa69e048432aa 100644
--- a/deps/npm/node_modules/@npmcli/arborist/package.json
+++ b/deps/npm/node_modules/@npmcli/arborist/package.json
@@ -1,6 +1,6 @@
{
"name": "@npmcli/arborist",
- "version": "6.2.2",
+ "version": "6.2.3",
"description": "Manage node_modules trees",
"dependencies": {
"@isaacs/string-locale-compare": "^1.1.0",
diff --git a/deps/npm/node_modules/libnpmdiff/package.json b/deps/npm/node_modules/libnpmdiff/package.json
index 1814f56957d119..cdd01c25c3ae54 100644
--- a/deps/npm/node_modules/libnpmdiff/package.json
+++ b/deps/npm/node_modules/libnpmdiff/package.json
@@ -1,6 +1,6 @@
{
"name": "libnpmdiff",
- "version": "5.0.10",
+ "version": "5.0.11",
"description": "The registry diff",
"repository": {
"type": "git",
@@ -46,7 +46,7 @@
"tap": "^16.3.4"
},
"dependencies": {
- "@npmcli/arborist": "^6.2.2",
+ "@npmcli/arborist": "^6.2.3",
"@npmcli/disparity-colors": "^3.0.0",
"@npmcli/installed-package-contents": "^2.0.0",
"binary-extensions": "^2.2.0",
diff --git a/deps/npm/node_modules/libnpmexec/package.json b/deps/npm/node_modules/libnpmexec/package.json
index 6e3696a3a7d053..f13b16ed17e529 100644
--- a/deps/npm/node_modules/libnpmexec/package.json
+++ b/deps/npm/node_modules/libnpmexec/package.json
@@ -1,6 +1,6 @@
{
"name": "libnpmexec",
- "version": "5.0.10",
+ "version": "5.0.11",
"files": [
"bin/",
"lib/"
@@ -60,7 +60,7 @@
"tap": "^16.3.4"
},
"dependencies": {
- "@npmcli/arborist": "^6.2.2",
+ "@npmcli/arborist": "^6.2.3",
"@npmcli/run-script": "^6.0.0",
"chalk": "^4.1.0",
"ci-info": "^3.7.1",
diff --git a/deps/npm/node_modules/libnpmfund/package.json b/deps/npm/node_modules/libnpmfund/package.json
index 21dae2a78bd616..36ec66de751031 100644
--- a/deps/npm/node_modules/libnpmfund/package.json
+++ b/deps/npm/node_modules/libnpmfund/package.json
@@ -1,6 +1,6 @@
{
"name": "libnpmfund",
- "version": "4.0.10",
+ "version": "4.0.11",
"main": "lib/index.js",
"files": [
"bin/",
@@ -45,7 +45,7 @@
"tap": "^16.3.4"
},
"dependencies": {
- "@npmcli/arborist": "^6.2.2"
+ "@npmcli/arborist": "^6.2.3"
},
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
diff --git a/deps/npm/node_modules/libnpmpack/package.json b/deps/npm/node_modules/libnpmpack/package.json
index 671e4b24720dbc..ef256ad38df7af 100644
--- a/deps/npm/node_modules/libnpmpack/package.json
+++ b/deps/npm/node_modules/libnpmpack/package.json
@@ -1,6 +1,6 @@
{
"name": "libnpmpack",
- "version": "5.0.10",
+ "version": "5.0.11",
"description": "Programmatic API for the bits behind npm pack",
"author": "GitHub Inc.",
"main": "lib/index.js",
@@ -36,7 +36,7 @@
"bugs": "https://github.com/npm/libnpmpack/issues",
"homepage": "https://npmjs.com/package/libnpmpack",
"dependencies": {
- "@npmcli/arborist": "^6.2.2",
+ "@npmcli/arborist": "^6.2.3",
"@npmcli/run-script": "^6.0.0",
"npm-package-arg": "^10.1.0",
"pacote": "^15.0.8"
diff --git a/deps/npm/node_modules/lru-cache/LICENSE b/deps/npm/node_modules/lru-cache/LICENSE
index 9b58a3e03d1df1..f785757cd63f86 100644
--- a/deps/npm/node_modules/lru-cache/LICENSE
+++ b/deps/npm/node_modules/lru-cache/LICENSE
@@ -1,6 +1,6 @@
The ISC License
-Copyright (c) 2010-2022 Isaac Z. Schlueter and Contributors
+Copyright (c) 2010-2023 Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
diff --git a/deps/npm/node_modules/lru-cache/index.d.ts b/deps/npm/node_modules/lru-cache/index.d.ts
index ceed413c70919e..e8af7c4de82f99 100644
--- a/deps/npm/node_modules/lru-cache/index.d.ts
+++ b/deps/npm/node_modules/lru-cache/index.d.ts
@@ -31,21 +31,36 @@
// Changes by Isaac Z. Schlueter released under the terms found in the
// LICENSE file within this project.
-//tslint:disable:member-access
+/**
+ * Integer greater than 0, representing some number of milliseconds, or the
+ * time at which a TTL started counting from.
+ */
+declare type LRUMilliseconds = number
+
+/**
+ * An integer greater than 0, reflecting the calculated size of items
+ */
+declare type LRUSize = number
+
+/**
+ * An integer greater than 0, reflecting a number of items
+ */
+declare type LRUCount = number
+
declare class LRUCache implements Iterable<[K, V]> {
constructor(options: LRUCache.Options)
/**
* Number of items in the cache.
- * Alias for `cache.size`
+ * Alias for {@link size}
*
- * @deprecated since 7.0 use `cache.size` instead
+ * @deprecated since 7.0 use {@link size} instead
*/
- public readonly length: number
+ public readonly length: LRUCount
- public readonly max: number
- public readonly maxSize: number
- public readonly maxEntrySize: number
+ public readonly max: LRUCount
+ public readonly maxSize: LRUSize
+ public readonly maxEntrySize: LRUSize
public readonly sizeCalculation:
| LRUCache.SizeCalculator
| undefined
@@ -55,8 +70,8 @@ declare class LRUCache implements Iterable<[K, V]> {
*/
public readonly disposeAfter: LRUCache.Disposer | null
public readonly noDisposeOnSet: boolean
- public readonly ttl: number
- public readonly ttlResolution: number
+ public readonly ttl: LRUMilliseconds
+ public readonly ttlResolution: LRUMilliseconds
public readonly ttlAutopurge: boolean
public readonly allowStale: boolean
public readonly updateAgeOnGet: boolean
@@ -72,12 +87,12 @@ declare class LRUCache implements Iterable<[K, V]> {
/**
* The total number of items held in the cache at the current moment.
*/
- public readonly size: number
+ public readonly size: LRUCount
/**
* The total size of items in cache when using size tracking.
*/
- public readonly calculatedSize: number
+ public readonly calculatedSize: LRUSize
/**
* Add a value to the cache.
@@ -89,36 +104,30 @@ declare class LRUCache implements Iterable<[K, V]> {
): this
/**
- * Return a value from the cache.
- * Will update the recency of the cache entry found.
- * If the key is not found, `get()` will return `undefined`.
- * This can be confusing when setting values specifically to `undefined`,
- * as in `cache.set(key, undefined)`. Use `cache.has()` to determine
- * whether a key is present in the cache at all.
+ * Return a value from the cache. Will update the recency of the cache entry
+ * found.
+ *
+ * If the key is not found, {@link get} will return `undefined`. This can be
+ * confusing when setting values specifically to `undefined`, as in
+ * `cache.set(key, undefined)`. Use {@link has} to determine whether a key is
+ * present in the cache at all.
*/
- // tslint:disable-next-line:no-unnecessary-generics
- public get(
- key: K,
- options?: LRUCache.GetOptions
- ): T | undefined
+ public get(key: K, options?: LRUCache.GetOptions): V | undefined
/**
- * Like `get()` but doesn't update recency or delete stale items.
- * Returns `undefined` if the item is stale, unless `allowStale` is set
+ * Like {@link get} but doesn't update recency or delete stale items.
+ * Returns `undefined` if the item is stale, unless {@link allowStale} is set
* either on the cache or in the options object.
*/
- // tslint:disable-next-line:no-unnecessary-generics
- public peek(
- key: K,
- options?: LRUCache.PeekOptions
- ): T | undefined
+ public peek(key: K, options?: LRUCache.PeekOptions): V | undefined
/**
* Check if a key is in the cache, without updating the recency of use.
* Will return false if the item is stale, even though it is technically
* in the cache.
- * Will not update item age unless `updateAgeOnHas` is set in the options
- * or constructor.
+ *
+ * Will not update item age unless {@link updateAgeOnHas} is set in the
+ * options or constructor.
*/
public has(key: K, options?: LRUCache.HasOptions): boolean
@@ -143,15 +152,14 @@ declare class LRUCache implements Iterable<[K, V]> {
* Find a value for which the supplied fn method returns a truthy value,
* similar to Array.find(). fn is called as fn(value, key, cache).
*/
- // tslint:disable-next-line:no-unnecessary-generics
- public find(
+ public find(
callbackFn: (
value: V,
key: K,
cache: this
) => boolean | undefined | void,
options?: LRUCache.GetOptions
- ): T
+ ): V | undefined
/**
* Call the supplied function on each item in the cache, in order from
@@ -164,7 +172,7 @@ declare class LRUCache implements Iterable<[K, V]> {
): void
/**
- * The same as `cache.forEach(...)` but items are iterated over in reverse
+ * The same as {@link forEach} but items are iterated over in reverse
* order. (ie, less recently used items are iterated over first.)
*/
public rforEach(
@@ -176,46 +184,49 @@ declare class LRUCache implements Iterable<[K, V]> {
* Return a generator yielding the keys in the cache,
* in order from most recently used to least recently used.
*/
- public keys(): Generator
+ public keys(): Generator
/**
- * Inverse order version of `cache.keys()`
+ * Inverse order version of {@link keys}
+ *
* Return a generator yielding the keys in the cache,
* in order from least recently used to most recently used.
*/
- public rkeys(): Generator
+ public rkeys(): Generator
/**
* Return a generator yielding the values in the cache,
* in order from most recently used to least recently used.
*/
- public values(): Generator
+ public values(): Generator
/**
- * Inverse order version of `cache.values()`
+ * Inverse order version of {@link values}
+ *
* Return a generator yielding the values in the cache,
* in order from least recently used to most recently used.
*/
- public rvalues(): Generator
+ public rvalues(): Generator
/**
* Return a generator yielding `[key, value]` pairs,
* in order from most recently used to least recently used.
*/
- public entries(): Generator<[K, V]>
+ public entries(): Generator<[K, V], void, void>
/**
- * Inverse order version of `cache.entries()`
+ * Inverse order version of {@link entries}
+ *
* Return a generator yielding `[key, value]` pairs,
* in order from least recently used to most recently used.
*/
- public rentries(): Generator<[K, V]>
+ public rentries(): Generator<[K, V], void, void>
/**
* Iterating over the cache itself yields the same results as
- * `cache.entries()`
+ * {@link entries}
*/
- public [Symbol.iterator](): Iterator<[K, V]>
+ public [Symbol.iterator](): Generator<[K, V], void, void>
/**
* Return an array of [key, entry] objects which can be passed to
@@ -262,23 +273,21 @@ declare class LRUCache implements Iterable<[K, V]> {
/**
* since: 7.6.0
*/
- // tslint:disable-next-line:no-unnecessary-generics
- public fetch(
+ public fetch(
key: K,
options?: LRUCache.FetchOptions
- ): Promise
+ ): Promise
/**
* since: 7.6.0
*/
- public getRemainingTTL(key: K): number
+ public getRemainingTTL(key: K): LRUMilliseconds
}
declare namespace LRUCache {
- type LRUMilliseconds = number
type DisposeReason = 'evict' | 'set' | 'delete'
- type SizeCalculator = (value: V, key: K) => number
+ type SizeCalculator = (value: V, key: K) => LRUSize
type Disposer = (
value: V,
key: K,
@@ -286,7 +295,7 @@ declare namespace LRUCache {
) => void
type Fetcher = (
key: K,
- staleValue: V,
+ staleValue: V | undefined,
options: FetcherOptions
) => Promise | V | void | undefined
@@ -296,12 +305,12 @@ declare namespace LRUCache {
*
* @deprecated since 7.0 use options.ttl instead
*/
- maxAge?: number
+ maxAge?: LRUMilliseconds
/**
- * alias for sizeCalculation
+ * alias for {@link sizeCalculation}
*
- * @deprecated since 7.0 use options.sizeCalculation instead
+ * @deprecated since 7.0 use {@link sizeCalculation} instead
*/
length?: SizeCalculator
@@ -318,12 +327,18 @@ declare namespace LRUCache {
* The number of most recently used items to keep.
* Note that we may store fewer items than this if maxSize is hit.
*/
- max: number
+ max: LRUCount
}
type MaybeMaxEntrySizeLimit =
| {
- maxEntrySize: number
+ /**
+ * The maximum allowed size for any single item in the cache.
+ *
+ * If a larger item is passed to {@link set} or returned by a
+ * {@link fetchMethod}, then it will not be stored in the cache.
+ */
+ maxEntrySize: LRUSize
sizeCalculation?: SizeCalculator
}
| {}
@@ -336,16 +351,22 @@ declare namespace LRUCache {
* to be stored. At the extreme, a single item of maxSize size
* will cause everything else in the cache to be dropped when it
* is added. Use with caution!
+ *
* Note also that size tracking can negatively impact performance,
* though for most cases, only minimally.
*/
- maxSize: number
+ maxSize: LRUSize
/**
* Function to calculate size of items. Useful if storing strings or
* buffers or other items where memory size depends on the object itself.
- * Also note that oversized items do NOT immediately get dropped from
- * the cache, though they will cause faster turnover in the storage.
+ *
+ * Items larger than {@link maxEntrySize} will not be stored in the cache.
+ *
+ * Note that when {@link maxSize} or {@link maxEntrySize} are set, every
+ * item added MUST have a size specified, either via a `sizeCalculation` in
+ * the constructor, or `sizeCalculation` or {@link size} options to
+ * {@link set}.
*/
sizeCalculation?: SizeCalculator
}
@@ -363,7 +384,7 @@ declare namespace LRUCache {
*
* Must be an integer number of ms, defaults to 0, which means "no TTL"
*/
- ttl: number
+ ttl: LRUMilliseconds
/**
* Boolean flag to tell the cache to not update the TTL when
@@ -386,12 +407,12 @@ declare namespace LRUCache {
*
* Setting this to a higher value will improve performance somewhat
* while using ttl tracking, albeit at the expense of keeping stale
- * items around a bit longer than intended.
+ * items around a bit longer than their TTLs would indicate.
*
* @default 1
* @since 7.1.0
*/
- ttlResolution?: number
+ ttlResolution?: LRUMilliseconds
/**
* Preemptively remove stale items from the cache.
@@ -400,7 +421,7 @@ declare namespace LRUCache {
* It is almost always best to just leave the stale items in
* the cache, and let them fall out as new items are added.
*
- * Note that this means that allowStale is a bit pointless,
+ * Note that this means that {@link allowStale} is a bit pointless,
* as stale items will be deleted almost as soon as they expire.
*
* Use with caution!
@@ -411,24 +432,24 @@ declare namespace LRUCache {
ttlAutopurge?: boolean
/**
- * Return stale items from cache.get() before disposing of them.
- * Return stale values from cache.fetch() while performing a call
- * to the `fetchMethod` in the background.
+ * Return stale items from {@link get} before disposing of them.
+ * Return stale values from {@link fetch} while performing a call
+ * to the {@link fetchMethod} in the background.
*
* @default false
*/
allowStale?: boolean
/**
- * Update the age of items on cache.get(), renewing their TTL
+ * Update the age of items on {@link get}, renewing their TTL
*
* @default false
*/
updateAgeOnGet?: boolean
/**
- * Do not delete stale items when they are retrieved with cache.get()
- * Note that the get() return value will still be `undefined` unless
+ * Do not delete stale items when they are retrieved with {@link get}.
+ * Note that the {@link get} return value will still be `undefined` unless
* allowStale is true.
*
* @default false
@@ -437,7 +458,7 @@ declare namespace LRUCache {
noDeleteOnStaleGet?: boolean
/**
- * Update the age of items on cache.has(), renewing their TTL
+ * Update the age of items on {@link has}, renewing their TTL
*
* @default false
*/
@@ -457,8 +478,8 @@ declare namespace LRUCache {
* cleanup tasks when items are no longer accessible. Called with `key,
* value`. It's called before actually removing the item from the
* internal cache, so it is *NOT* safe to re-add them.
- * Use `disposeAfter` if you wish to dispose items after they have been
- * full removed, when it is safe to add them back to the cache.
+ * Use {@link disposeAfter} if you wish to dispose items after they have
+ * been full removed, when it is safe to add them back to the cache.
*/
dispose?: Disposer
@@ -476,27 +497,29 @@ declare namespace LRUCache {
/**
* Set to true to suppress calling the dispose() function if the entry
* key is still accessible within the cache.
- * This may be overridden by passing an options object to cache.set().
+ * This may be overridden by passing an options object to {@link set}.
*
* @default false
*/
noDisposeOnSet?: boolean
/**
- * `fetchMethod` Function that is used to make background asynchronous
- * fetches. Called with `fetchMethod(key, staleValue)`. May return a
- * Promise.
+ * Function that is used to make background asynchronous fetches. Called
+ * with `fetchMethod(key, staleValue, { signal, options, context })`.
*
- * If `fetchMethod` is not provided, then `cache.fetch(key)` is
+ * If `fetchMethod` is not provided, then {@link fetch} is
* equivalent to `Promise.resolve(cache.get(key))`.
*
+ * The `fetchMethod` should ONLY return `undefined` in cases where the
+ * abort controller has sent an abort signal.
+ *
* @since 7.6.0
*/
fetchMethod?: LRUCache.Fetcher
/**
* Set to true to suppress the deletion of stale data when a
- * `fetchMethod` throws an error or returns a rejected promise
+ * {@link fetchMethod} throws an error or returns a rejected promise
*
* @default false
* @since 7.10.0
@@ -504,9 +527,21 @@ declare namespace LRUCache {
noDeleteOnFetchRejection?: boolean
/**
- * Set to any value in the constructor or fetch() options to
- * pass arbitrary data to the fetch() method in the options.context
- * field.
+ * Set to true to allow returning stale data when a {@link fetchMethod}
+ * throws an error or returns a rejected promise. Note that this
+ * differs from using {@link allowStale} in that stale data will
+ * ONLY be returned in the case that the fetch fails, not any other
+ * times.
+ *
+ * @default false
+ * @since 7.16.0
+ */
+ allowStaleOnFetchRejection?: boolean
+
+ /**
+ * Set to any value in the constructor or {@link fetch} options to
+ * pass arbitrary data to the {@link fetchMethod} in the {@link context}
+ * options field.
*
* @since 7.12.0
*/
@@ -520,24 +555,41 @@ declare namespace LRUCache {
/**
* options which override the options set in the LRUCache constructor
- * when making `cache.set()` calls.
+ * when making calling {@link set}.
*/
interface SetOptions {
/**
* A value for the size of the entry, prevents calls to
- * `sizeCalculation` function.
+ * {@link sizeCalculation}.
+ *
+ * Items larger than {@link maxEntrySize} will not be stored in the cache.
+ *
+ * Note that when {@link maxSize} or {@link maxEntrySize} are set, every
+ * item added MUST have a size specified, either via a `sizeCalculation` in
+ * the constructor, or {@link sizeCalculation} or `size` options to
+ * {@link set}.
+ */
+ size?: LRUSize
+ /**
+ * Overrides the {@link sizeCalculation} method set in the constructor.
+ *
+ * Items larger than {@link maxEntrySize} will not be stored in the cache.
+ *
+ * Note that when {@link maxSize} or {@link maxEntrySize} are set, every
+ * item added MUST have a size specified, either via a `sizeCalculation` in
+ * the constructor, or `sizeCalculation` or {@link size} options to
+ * {@link set}.
*/
- size?: number
sizeCalculation?: SizeCalculator
- ttl?: number
- start?: number
+ ttl?: LRUMilliseconds
+ start?: LRUMilliseconds
noDisposeOnSet?: boolean
noUpdateTTL?: boolean
}
/**
* options which override the options set in the LRUCAche constructor
- * when making `cache.has()` calls.
+ * when calling {@link has}.
*/
interface HasOptions {
updateAgeOnHas?: boolean
@@ -545,7 +597,7 @@ declare namespace LRUCache {
/**
* options which override the options set in the LRUCache constructor
- * when making `cache.get()` calls.
+ * when calling {@link get}.
*/
interface GetOptions {
allowStale?: boolean
@@ -555,29 +607,40 @@ declare namespace LRUCache {
/**
* options which override the options set in the LRUCache constructor
- * when making `cache.peek()` calls.
+ * when calling {@link peek}.
*/
interface PeekOptions {
allowStale?: boolean
}
+ /**
+ * Options object passed to the {@link fetchMethod}
+ *
+ * May be mutated by the {@link fetchMethod} to affect the behavior of the
+ * resulting {@link set} operation on resolution, or in the case of
+ * {@link noDeleteOnFetchRejection} and {@link allowStaleOnFetchRejection},
+ * the handling of failure.
+ */
interface FetcherFetchOptions {
allowStale?: boolean
updateAgeOnGet?: boolean
noDeleteOnStaleGet?: boolean
- size?: number
+ size?: LRUSize
sizeCalculation?: SizeCalculator
- ttl?: number
+ ttl?: LRUMilliseconds
noDisposeOnSet?: boolean
noUpdateTTL?: boolean
noDeleteOnFetchRejection?: boolean
+ allowStaleOnFetchRejection?: boolean
}
/**
* options which override the options set in the LRUCache constructor
- * when making `cache.fetch()` calls.
+ * when calling {@link fetch}.
+ *
* This is the union of GetOptions and SetOptions, plus
- * `noDeleteOnFetchRejection`, `forceRefresh`, and `fetchContext`
+ * {@link noDeleteOnFetchRejection}, {@link allowStaleOnFetchRejection},
+ * {@link forceRefresh}, and {@link fetchContext}
*/
interface FetchOptions extends FetcherFetchOptions {
forceRefresh?: boolean
@@ -587,14 +650,17 @@ declare namespace LRUCache {
interface FetcherOptions {
signal: AbortSignal
options: FetcherFetchOptions
+ /**
+ * Object provided in the {@link fetchContext} option
+ */
context: any
}
interface Entry {
value: V
- ttl?: number
- size?: number
- start?: number
+ ttl?: LRUMilliseconds
+ size?: LRUSize
+ start?: LRUMilliseconds
}
}
diff --git a/deps/npm/node_modules/lru-cache/index.js b/deps/npm/node_modules/lru-cache/index.js
index fa53c12096cf64..f4be3476d4dbc1 100644
--- a/deps/npm/node_modules/lru-cache/index.js
+++ b/deps/npm/node_modules/lru-cache/index.js
@@ -17,8 +17,12 @@ const AC = hasAbortController
constructor() {
this.signal = new AS()
}
- abort() {
- this.signal.dispatchEvent('abort')
+ abort(reason = new Error('This operation was aborted')) {
+ this.signal.reason = reason
+ this.signal.dispatchEvent({
+ type: 'abort',
+ target: this.signal,
+ })
}
}
@@ -31,13 +35,13 @@ const AS = hasAbortSignal
? AC.AbortController
: class AbortSignal {
constructor() {
+ this.reason = undefined
this.aborted = false
this._listeners = []
}
- dispatchEvent(type) {
- if (type === 'abort') {
+ dispatchEvent(e) {
+ if (e.type === 'abort') {
this.aborted = true
- const e = { type, target: this }
this.onabort(e)
this._listeners.forEach(f => f(e), this)
}
@@ -163,6 +167,7 @@ class LRUCache {
fetchContext,
noDeleteOnFetchRejection,
noDeleteOnStaleGet,
+ allowStaleOnFetchRejection,
} = options
// deprecated options, don't trigger a warning for getting them if
@@ -232,6 +237,7 @@ class LRUCache {
this.noDisposeOnSet = !!noDisposeOnSet
this.noUpdateTTL = !!noUpdateTTL
this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection
+ this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection
// NB: maxEntrySize is set to maxSize if it's set
if (this.maxEntrySize !== 0) {
@@ -365,9 +371,9 @@ class LRUCache {
)
}
}
- updateItemAge(index) {}
- setItemTTL(index, ttl, start) {}
- isStale(index) {
+ updateItemAge(_index) {}
+ setItemTTL(_index, _ttl, _start) {}
+ isStale(_index) {
return false
}
@@ -397,7 +403,9 @@ class LRUCache {
}
} else {
throw new TypeError(
- 'invalid size value (must be positive integer)'
+ 'invalid size value (must be positive integer). ' +
+ 'When maxSize or maxEntrySize is used, sizeCalculation or size ' +
+ 'must be set.'
)
}
}
@@ -414,9 +422,9 @@ class LRUCache {
this.calculatedSize += this.sizes[index]
}
}
- removeItemSize(index) {}
- addItemSize(index, size) {}
- requireSize(k, v, size, sizeCalculation) {
+ removeItemSize(_index) {}
+ addItemSize(_index, _size) {}
+ requireSize(_k, _v, size, sizeCalculation) {
if (size || sizeCalculation) {
throw new TypeError(
'cannot set size without setting maxSize or maxEntrySize on cache'
@@ -466,34 +474,46 @@ class LRUCache {
*entries() {
for (const i of this.indexes()) {
- yield [this.keyList[i], this.valList[i]]
+ if (!this.isBackgroundFetch(this.valList[i])) {
+ yield [this.keyList[i], this.valList[i]]
+ }
}
}
*rentries() {
for (const i of this.rindexes()) {
- yield [this.keyList[i], this.valList[i]]
+ if (!this.isBackgroundFetch(this.valList[i])) {
+ yield [this.keyList[i], this.valList[i]]
+ }
}
}
*keys() {
for (const i of this.indexes()) {
- yield this.keyList[i]
+ if (!this.isBackgroundFetch(this.valList[i])) {
+ yield this.keyList[i]
+ }
}
}
*rkeys() {
for (const i of this.rindexes()) {
- yield this.keyList[i]
+ if (!this.isBackgroundFetch(this.valList[i])) {
+ yield this.keyList[i]
+ }
}
}
*values() {
for (const i of this.indexes()) {
- yield this.valList[i]
+ if (!this.isBackgroundFetch(this.valList[i])) {
+ yield this.valList[i]
+ }
}
}
*rvalues() {
for (const i of this.rindexes()) {
- yield this.valList[i]
+ if (!this.isBackgroundFetch(this.valList[i])) {
+ yield this.valList[i]
+ }
}
}
@@ -545,6 +565,7 @@ class LRUCache {
const value = this.isBackgroundFetch(v)
? v.__staleWhileFetching
: v
+ if (value === undefined) continue
const entry = { value }
if (this.ttls) {
entry.ttl = this.ttls[i]
@@ -575,7 +596,7 @@ class LRUCache {
}
}
- dispose(v, k, reason) {}
+ dispose(_v, _k, _reason) {}
set(
k,
@@ -613,10 +634,11 @@ class LRUCache {
noUpdateTTL = false
} else {
// update
+ this.moveToTail(index)
const oldVal = this.valList[index]
if (v !== oldVal) {
if (this.isBackgroundFetch(oldVal)) {
- oldVal.__abortController.abort()
+ oldVal.__abortController.abort(new Error('replaced'))
} else {
if (!noDisposeOnSet) {
this.dispose(oldVal, k, 'set')
@@ -629,7 +651,6 @@ class LRUCache {
this.valList[index] = v
this.addItemSize(index, size)
}
- this.moveToTail(index)
}
if (ttl !== 0 && this.ttl === 0 && !this.ttls) {
this.initializeTTLTracking()
@@ -672,7 +693,7 @@ class LRUCache {
const k = this.keyList[head]
const v = this.valList[head]
if (this.isBackgroundFetch(v)) {
- v.__abortController.abort()
+ v.__abortController.abort(new Error('evicted'))
} else {
this.dispose(v, k, 'evict')
if (this.disposeAfter) {
@@ -729,14 +750,19 @@ class LRUCache {
const cb = v => {
if (!ac.signal.aborted) {
this.set(k, v, fetchOpts.options)
+ return v
+ } else {
+ return eb(ac.signal.reason)
}
- return v
}
const eb = er => {
if (this.valList[index] === p) {
- const del =
- !options.noDeleteOnFetchRejection ||
- p.__staleWhileFetching === undefined
+ // if we allow stale on fetch rejections, then we need to ensure that
+ // the stale value is not removed from the cache when the fetch fails.
+ const noDelete =
+ options.noDeleteOnFetchRejection ||
+ options.allowStaleOnFetchRejection
+ const del = !noDelete || p.__staleWhileFetching === undefined
if (del) {
this.delete(k)
} else {
@@ -745,11 +771,16 @@ class LRUCache {
this.valList[index] = p.__staleWhileFetching
}
}
- if (p.__returned === p) {
+ if (options.allowStaleOnFetchRejection) {
+ return p.__staleWhileFetching
+ } else if (p.__returned === p) {
throw er
}
}
- const pcall = res => res(this.fetchMethod(k, v, fetchOpts))
+ const pcall = (res, rej) => {
+ ac.signal.addEventListener('abort', () => res())
+ this.fetchMethod(k, v, fetchOpts).then(res, rej)
+ }
const p = new Promise(pcall).then(cb, eb)
p.__abortController = ac
p.__staleWhileFetching = v
@@ -793,8 +824,10 @@ class LRUCache {
noUpdateTTL = this.noUpdateTTL,
// fetch exclusive options
noDeleteOnFetchRejection = this.noDeleteOnFetchRejection,
+ allowStaleOnFetchRejection = this.allowStaleOnFetchRejection,
fetchContext = this.fetchContext,
forceRefresh = false,
+ signal,
} = {}
) {
if (!this.fetchMethod) {
@@ -815,6 +848,8 @@ class LRUCache {
sizeCalculation,
noUpdateTTL,
noDeleteOnFetchRejection,
+ allowStaleOnFetchRejection,
+ signal,
}
let index = this.keyMap.get(k)
@@ -929,7 +964,7 @@ class LRUCache {
this.removeItemSize(index)
const v = this.valList[index]
if (this.isBackgroundFetch(v)) {
- v.__abortController.abort()
+ v.__abortController.abort(new Error('deleted'))
} else {
this.dispose(v, k, 'delete')
if (this.disposeAfter) {
@@ -964,7 +999,7 @@ class LRUCache {
for (const index of this.rindexes({ allowStale: true })) {
const v = this.valList[index]
if (this.isBackgroundFetch(v)) {
- v.__abortController.abort()
+ v.__abortController.abort(new Error('deleted'))
} else {
const k = this.keyList[index]
this.dispose(v, k, 'delete')
diff --git a/deps/npm/node_modules/lru-cache/index.mjs b/deps/npm/node_modules/lru-cache/index.mjs
new file mode 100644
index 00000000000000..e69e77fbb34566
--- /dev/null
+++ b/deps/npm/node_modules/lru-cache/index.mjs
@@ -0,0 +1,1053 @@
+const perf =
+ typeof performance === 'object' &&
+ performance &&
+ typeof performance.now === 'function'
+ ? performance
+ : Date
+
+const hasAbortController = typeof AbortController === 'function'
+
+// minimal backwards-compatibility polyfill
+// this doesn't have nearly all the checks and whatnot that
+// actual AbortController/Signal has, but it's enough for
+// our purposes, and if used properly, behaves the same.
+const AC = hasAbortController
+ ? AbortController
+ : class AbortController {
+ constructor() {
+ this.signal = new AS()
+ }
+ abort(reason = new Error('This operation was aborted')) {
+ this.signal.reason = reason
+ this.signal.dispatchEvent({
+ type: 'abort',
+ target: this.signal,
+ })
+ }
+ }
+
+const hasAbortSignal = typeof AbortSignal === 'function'
+// Some polyfills put this on the AC class, not global
+const hasACAbortSignal = typeof AC.AbortSignal === 'function'
+const AS = hasAbortSignal
+ ? AbortSignal
+ : hasACAbortSignal
+ ? AC.AbortController
+ : class AbortSignal {
+ constructor() {
+ this.reason = undefined
+ this.aborted = false
+ this._listeners = []
+ }
+ dispatchEvent(e) {
+ if (e.type === 'abort') {
+ this.aborted = true
+ this.onabort(e)
+ this._listeners.forEach(f => f(e), this)
+ }
+ }
+ onabort() {}
+ addEventListener(ev, fn) {
+ if (ev === 'abort') {
+ this._listeners.push(fn)
+ }
+ }
+ removeEventListener(ev, fn) {
+ if (ev === 'abort') {
+ this._listeners = this._listeners.filter(f => f !== fn)
+ }
+ }
+ }
+
+const warned = new Set()
+const deprecatedOption = (opt, instead) => {
+ const code = `LRU_CACHE_OPTION_${opt}`
+ if (shouldWarn(code)) {
+ warn(code, `${opt} option`, `options.${instead}`, LRUCache)
+ }
+}
+const deprecatedMethod = (method, instead) => {
+ const code = `LRU_CACHE_METHOD_${method}`
+ if (shouldWarn(code)) {
+ const { prototype } = LRUCache
+ const { get } = Object.getOwnPropertyDescriptor(prototype, method)
+ warn(code, `${method} method`, `cache.${instead}()`, get)
+ }
+}
+const deprecatedProperty = (field, instead) => {
+ const code = `LRU_CACHE_PROPERTY_${field}`
+ if (shouldWarn(code)) {
+ const { prototype } = LRUCache
+ const { get } = Object.getOwnPropertyDescriptor(prototype, field)
+ warn(code, `${field} property`, `cache.${instead}`, get)
+ }
+}
+
+const emitWarning = (...a) => {
+ typeof process === 'object' &&
+ process &&
+ typeof process.emitWarning === 'function'
+ ? process.emitWarning(...a)
+ : console.error(...a)
+}
+
+const shouldWarn = code => !warned.has(code)
+
+const warn = (code, what, instead, fn) => {
+ warned.add(code)
+ const msg = `The ${what} is deprecated. Please use ${instead} instead.`
+ emitWarning(msg, 'DeprecationWarning', code, fn)
+}
+
+const isPosInt = n => n && n === Math.floor(n) && n > 0 && isFinite(n)
+
+/* istanbul ignore next - This is a little bit ridiculous, tbh.
+ * The maximum array length is 2^32-1 or thereabouts on most JS impls.
+ * And well before that point, you're caching the entire world, I mean,
+ * that's ~32GB of just integers for the next/prev links, plus whatever
+ * else to hold that many keys and values. Just filling the memory with
+ * zeroes at init time is brutal when you get that big.
+ * But why not be complete?
+ * Maybe in the future, these limits will have expanded. */
+const getUintArray = max =>
+ !isPosInt(max)
+ ? null
+ : max <= Math.pow(2, 8)
+ ? Uint8Array
+ : max <= Math.pow(2, 16)
+ ? Uint16Array
+ : max <= Math.pow(2, 32)
+ ? Uint32Array
+ : max <= Number.MAX_SAFE_INTEGER
+ ? ZeroArray
+ : null
+
+class ZeroArray extends Array {
+ constructor(size) {
+ super(size)
+ this.fill(0)
+ }
+}
+
+class Stack {
+ constructor(max) {
+ if (max === 0) {
+ return []
+ }
+ const UintArray = getUintArray(max)
+ this.heap = new UintArray(max)
+ this.length = 0
+ }
+ push(n) {
+ this.heap[this.length++] = n
+ }
+ pop() {
+ return this.heap[--this.length]
+ }
+}
+
+class LRUCache {
+ constructor(options = {}) {
+ const {
+ max = 0,
+ ttl,
+ ttlResolution = 1,
+ ttlAutopurge,
+ updateAgeOnGet,
+ updateAgeOnHas,
+ allowStale,
+ dispose,
+ disposeAfter,
+ noDisposeOnSet,
+ noUpdateTTL,
+ maxSize = 0,
+ maxEntrySize = 0,
+ sizeCalculation,
+ fetchMethod,
+ fetchContext,
+ noDeleteOnFetchRejection,
+ noDeleteOnStaleGet,
+ allowStaleOnFetchRejection,
+ } = options
+
+ // deprecated options, don't trigger a warning for getting them if
+ // the thing being passed in is another LRUCache we're copying.
+ const { length, maxAge, stale } =
+ options instanceof LRUCache ? {} : options
+
+ if (max !== 0 && !isPosInt(max)) {
+ throw new TypeError('max option must be a nonnegative integer')
+ }
+
+ const UintArray = max ? getUintArray(max) : Array
+ if (!UintArray) {
+ throw new Error('invalid max value: ' + max)
+ }
+
+ this.max = max
+ this.maxSize = maxSize
+ this.maxEntrySize = maxEntrySize || this.maxSize
+ this.sizeCalculation = sizeCalculation || length
+ if (this.sizeCalculation) {
+ if (!this.maxSize && !this.maxEntrySize) {
+ throw new TypeError(
+ 'cannot set sizeCalculation without setting maxSize or maxEntrySize'
+ )
+ }
+ if (typeof this.sizeCalculation !== 'function') {
+ throw new TypeError('sizeCalculation set to non-function')
+ }
+ }
+
+ this.fetchMethod = fetchMethod || null
+ if (this.fetchMethod && typeof this.fetchMethod !== 'function') {
+ throw new TypeError(
+ 'fetchMethod must be a function if specified'
+ )
+ }
+
+ this.fetchContext = fetchContext
+ if (!this.fetchMethod && fetchContext !== undefined) {
+ throw new TypeError(
+ 'cannot set fetchContext without fetchMethod'
+ )
+ }
+
+ this.keyMap = new Map()
+ this.keyList = new Array(max).fill(null)
+ this.valList = new Array(max).fill(null)
+ this.next = new UintArray(max)
+ this.prev = new UintArray(max)
+ this.head = 0
+ this.tail = 0
+ this.free = new Stack(max)
+ this.initialFill = 1
+ this.size = 0
+
+ if (typeof dispose === 'function') {
+ this.dispose = dispose
+ }
+ if (typeof disposeAfter === 'function') {
+ this.disposeAfter = disposeAfter
+ this.disposed = []
+ } else {
+ this.disposeAfter = null
+ this.disposed = null
+ }
+ this.noDisposeOnSet = !!noDisposeOnSet
+ this.noUpdateTTL = !!noUpdateTTL
+ this.noDeleteOnFetchRejection = !!noDeleteOnFetchRejection
+ this.allowStaleOnFetchRejection = !!allowStaleOnFetchRejection
+
+ // NB: maxEntrySize is set to maxSize if it's set
+ if (this.maxEntrySize !== 0) {
+ if (this.maxSize !== 0) {
+ if (!isPosInt(this.maxSize)) {
+ throw new TypeError(
+ 'maxSize must be a positive integer if specified'
+ )
+ }
+ }
+ if (!isPosInt(this.maxEntrySize)) {
+ throw new TypeError(
+ 'maxEntrySize must be a positive integer if specified'
+ )
+ }
+ this.initializeSizeTracking()
+ }
+
+ this.allowStale = !!allowStale || !!stale
+ this.noDeleteOnStaleGet = !!noDeleteOnStaleGet
+ this.updateAgeOnGet = !!updateAgeOnGet
+ this.updateAgeOnHas = !!updateAgeOnHas
+ this.ttlResolution =
+ isPosInt(ttlResolution) || ttlResolution === 0
+ ? ttlResolution
+ : 1
+ this.ttlAutopurge = !!ttlAutopurge
+ this.ttl = ttl || maxAge || 0
+ if (this.ttl) {
+ if (!isPosInt(this.ttl)) {
+ throw new TypeError(
+ 'ttl must be a positive integer if specified'
+ )
+ }
+ this.initializeTTLTracking()
+ }
+
+ // do not allow completely unbounded caches
+ if (this.max === 0 && this.ttl === 0 && this.maxSize === 0) {
+ throw new TypeError(
+ 'At least one of max, maxSize, or ttl is required'
+ )
+ }
+ if (!this.ttlAutopurge && !this.max && !this.maxSize) {
+ const code = 'LRU_CACHE_UNBOUNDED'
+ if (shouldWarn(code)) {
+ warned.add(code)
+ const msg =
+ 'TTL caching without ttlAutopurge, max, or maxSize can ' +
+ 'result in unbounded memory consumption.'
+ emitWarning(msg, 'UnboundedCacheWarning', code, LRUCache)
+ }
+ }
+
+ if (stale) {
+ deprecatedOption('stale', 'allowStale')
+ }
+ if (maxAge) {
+ deprecatedOption('maxAge', 'ttl')
+ }
+ if (length) {
+ deprecatedOption('length', 'sizeCalculation')
+ }
+ }
+
+ getRemainingTTL(key) {
+ return this.has(key, { updateAgeOnHas: false }) ? Infinity : 0
+ }
+
+ initializeTTLTracking() {
+ this.ttls = new ZeroArray(this.max)
+ this.starts = new ZeroArray(this.max)
+
+ this.setItemTTL = (index, ttl, start = perf.now()) => {
+ this.starts[index] = ttl !== 0 ? start : 0
+ this.ttls[index] = ttl
+ if (ttl !== 0 && this.ttlAutopurge) {
+ const t = setTimeout(() => {
+ if (this.isStale(index)) {
+ this.delete(this.keyList[index])
+ }
+ }, ttl + 1)
+ /* istanbul ignore else - unref() not supported on all platforms */
+ if (t.unref) {
+ t.unref()
+ }
+ }
+ }
+
+ this.updateItemAge = index => {
+ this.starts[index] = this.ttls[index] !== 0 ? perf.now() : 0
+ }
+
+ // debounce calls to perf.now() to 1s so we're not hitting
+ // that costly call repeatedly.
+ let cachedNow = 0
+ const getNow = () => {
+ const n = perf.now()
+ if (this.ttlResolution > 0) {
+ cachedNow = n
+ const t = setTimeout(
+ () => (cachedNow = 0),
+ this.ttlResolution
+ )
+ /* istanbul ignore else - not available on all platforms */
+ if (t.unref) {
+ t.unref()
+ }
+ }
+ return n
+ }
+
+ this.getRemainingTTL = key => {
+ const index = this.keyMap.get(key)
+ if (index === undefined) {
+ return 0
+ }
+ return this.ttls[index] === 0 || this.starts[index] === 0
+ ? Infinity
+ : this.starts[index] +
+ this.ttls[index] -
+ (cachedNow || getNow())
+ }
+
+ this.isStale = index => {
+ return (
+ this.ttls[index] !== 0 &&
+ this.starts[index] !== 0 &&
+ (cachedNow || getNow()) - this.starts[index] >
+ this.ttls[index]
+ )
+ }
+ }
+ updateItemAge(_index) {}
+ setItemTTL(_index, _ttl, _start) {}
+ isStale(_index) {
+ return false
+ }
+
+ initializeSizeTracking() {
+ this.calculatedSize = 0
+ this.sizes = new ZeroArray(this.max)
+ this.removeItemSize = index => {
+ this.calculatedSize -= this.sizes[index]
+ this.sizes[index] = 0
+ }
+ this.requireSize = (k, v, size, sizeCalculation) => {
+ // provisionally accept background fetches.
+ // actual value size will be checked when they return.
+ if (this.isBackgroundFetch(v)) {
+ return 0
+ }
+ if (!isPosInt(size)) {
+ if (sizeCalculation) {
+ if (typeof sizeCalculation !== 'function') {
+ throw new TypeError('sizeCalculation must be a function')
+ }
+ size = sizeCalculation(v, k)
+ if (!isPosInt(size)) {
+ throw new TypeError(
+ 'sizeCalculation return invalid (expect positive integer)'
+ )
+ }
+ } else {
+ throw new TypeError(
+ 'invalid size value (must be positive integer). ' +
+ 'When maxSize or maxEntrySize is used, sizeCalculation or size ' +
+ 'must be set.'
+ )
+ }
+ }
+ return size
+ }
+ this.addItemSize = (index, size) => {
+ this.sizes[index] = size
+ if (this.maxSize) {
+ const maxSize = this.maxSize - this.sizes[index]
+ while (this.calculatedSize > maxSize) {
+ this.evict(true)
+ }
+ }
+ this.calculatedSize += this.sizes[index]
+ }
+ }
+ removeItemSize(_index) {}
+ addItemSize(_index, _size) {}
+ requireSize(_k, _v, size, sizeCalculation) {
+ if (size || sizeCalculation) {
+ throw new TypeError(
+ 'cannot set size without setting maxSize or maxEntrySize on cache'
+ )
+ }
+ }
+
+ *indexes({ allowStale = this.allowStale } = {}) {
+ if (this.size) {
+ for (let i = this.tail; true; ) {
+ if (!this.isValidIndex(i)) {
+ break
+ }
+ if (allowStale || !this.isStale(i)) {
+ yield i
+ }
+ if (i === this.head) {
+ break
+ } else {
+ i = this.prev[i]
+ }
+ }
+ }
+ }
+
+ *rindexes({ allowStale = this.allowStale } = {}) {
+ if (this.size) {
+ for (let i = this.head; true; ) {
+ if (!this.isValidIndex(i)) {
+ break
+ }
+ if (allowStale || !this.isStale(i)) {
+ yield i
+ }
+ if (i === this.tail) {
+ break
+ } else {
+ i = this.next[i]
+ }
+ }
+ }
+ }
+
+ isValidIndex(index) {
+ return this.keyMap.get(this.keyList[index]) === index
+ }
+
+ *entries() {
+ for (const i of this.indexes()) {
+ if (!this.isBackgroundFetch(this.valList[i])) {
+ yield [this.keyList[i], this.valList[i]]
+ }
+ }
+ }
+ *rentries() {
+ for (const i of this.rindexes()) {
+ if (!this.isBackgroundFetch(this.valList[i])) {
+ yield [this.keyList[i], this.valList[i]]
+ }
+ }
+ }
+
+ *keys() {
+ for (const i of this.indexes()) {
+ if (!this.isBackgroundFetch(this.valList[i])) {
+ yield this.keyList[i]
+ }
+ }
+ }
+ *rkeys() {
+ for (const i of this.rindexes()) {
+ if (!this.isBackgroundFetch(this.valList[i])) {
+ yield this.keyList[i]
+ }
+ }
+ }
+
+ *values() {
+ for (const i of this.indexes()) {
+ if (!this.isBackgroundFetch(this.valList[i])) {
+ yield this.valList[i]
+ }
+ }
+ }
+ *rvalues() {
+ for (const i of this.rindexes()) {
+ if (!this.isBackgroundFetch(this.valList[i])) {
+ yield this.valList[i]
+ }
+ }
+ }
+
+ [Symbol.iterator]() {
+ return this.entries()
+ }
+
+ find(fn, getOptions = {}) {
+ for (const i of this.indexes()) {
+ if (fn(this.valList[i], this.keyList[i], this)) {
+ return this.get(this.keyList[i], getOptions)
+ }
+ }
+ }
+
+ forEach(fn, thisp = this) {
+ for (const i of this.indexes()) {
+ fn.call(thisp, this.valList[i], this.keyList[i], this)
+ }
+ }
+
+ rforEach(fn, thisp = this) {
+ for (const i of this.rindexes()) {
+ fn.call(thisp, this.valList[i], this.keyList[i], this)
+ }
+ }
+
+ get prune() {
+ deprecatedMethod('prune', 'purgeStale')
+ return this.purgeStale
+ }
+
+ purgeStale() {
+ let deleted = false
+ for (const i of this.rindexes({ allowStale: true })) {
+ if (this.isStale(i)) {
+ this.delete(this.keyList[i])
+ deleted = true
+ }
+ }
+ return deleted
+ }
+
+ dump() {
+ const arr = []
+ for (const i of this.indexes({ allowStale: true })) {
+ const key = this.keyList[i]
+ const v = this.valList[i]
+ const value = this.isBackgroundFetch(v)
+ ? v.__staleWhileFetching
+ : v
+ if (value === undefined) continue
+ const entry = { value }
+ if (this.ttls) {
+ entry.ttl = this.ttls[i]
+ // always dump the start relative to a portable timestamp
+ // it's ok for this to be a bit slow, it's a rare operation.
+ const age = perf.now() - this.starts[i]
+ entry.start = Math.floor(Date.now() - age)
+ }
+ if (this.sizes) {
+ entry.size = this.sizes[i]
+ }
+ arr.unshift([key, entry])
+ }
+ return arr
+ }
+
+ load(arr) {
+ this.clear()
+ for (const [key, entry] of arr) {
+ if (entry.start) {
+ // entry.start is a portable timestamp, but we may be using
+ // node's performance.now(), so calculate the offset.
+ // it's ok for this to be a bit slow, it's a rare operation.
+ const age = Date.now() - entry.start
+ entry.start = perf.now() - age
+ }
+ this.set(key, entry.value, entry)
+ }
+ }
+
+ dispose(_v, _k, _reason) {}
+
+ set(
+ k,
+ v,
+ {
+ ttl = this.ttl,
+ start,
+ noDisposeOnSet = this.noDisposeOnSet,
+ size = 0,
+ sizeCalculation = this.sizeCalculation,
+ noUpdateTTL = this.noUpdateTTL,
+ } = {}
+ ) {
+ size = this.requireSize(k, v, size, sizeCalculation)
+ // if the item doesn't fit, don't do anything
+ // NB: maxEntrySize set to maxSize by default
+ if (this.maxEntrySize && size > this.maxEntrySize) {
+ // have to delete, in case a background fetch is there already.
+ // in non-async cases, this is a no-op
+ this.delete(k)
+ return this
+ }
+ let index = this.size === 0 ? undefined : this.keyMap.get(k)
+ if (index === undefined) {
+ // addition
+ index = this.newIndex()
+ this.keyList[index] = k
+ this.valList[index] = v
+ this.keyMap.set(k, index)
+ this.next[this.tail] = index
+ this.prev[index] = this.tail
+ this.tail = index
+ this.size++
+ this.addItemSize(index, size)
+ noUpdateTTL = false
+ } else {
+ // update
+ this.moveToTail(index)
+ const oldVal = this.valList[index]
+ if (v !== oldVal) {
+ if (this.isBackgroundFetch(oldVal)) {
+ oldVal.__abortController.abort(new Error('replaced'))
+ } else {
+ if (!noDisposeOnSet) {
+ this.dispose(oldVal, k, 'set')
+ if (this.disposeAfter) {
+ this.disposed.push([oldVal, k, 'set'])
+ }
+ }
+ }
+ this.removeItemSize(index)
+ this.valList[index] = v
+ this.addItemSize(index, size)
+ }
+ }
+ if (ttl !== 0 && this.ttl === 0 && !this.ttls) {
+ this.initializeTTLTracking()
+ }
+ if (!noUpdateTTL) {
+ this.setItemTTL(index, ttl, start)
+ }
+ if (this.disposeAfter) {
+ while (this.disposed.length) {
+ this.disposeAfter(...this.disposed.shift())
+ }
+ }
+ return this
+ }
+
+ newIndex() {
+ if (this.size === 0) {
+ return this.tail
+ }
+ if (this.size === this.max && this.max !== 0) {
+ return this.evict(false)
+ }
+ if (this.free.length !== 0) {
+ return this.free.pop()
+ }
+ // initial fill, just keep writing down the list
+ return this.initialFill++
+ }
+
+ pop() {
+ if (this.size) {
+ const val = this.valList[this.head]
+ this.evict(true)
+ return val
+ }
+ }
+
+ evict(free) {
+ const head = this.head
+ const k = this.keyList[head]
+ const v = this.valList[head]
+ if (this.isBackgroundFetch(v)) {
+ v.__abortController.abort(new Error('evicted'))
+ } else {
+ this.dispose(v, k, 'evict')
+ if (this.disposeAfter) {
+ this.disposed.push([v, k, 'evict'])
+ }
+ }
+ this.removeItemSize(head)
+ // if we aren't about to use the index, then null these out
+ if (free) {
+ this.keyList[head] = null
+ this.valList[head] = null
+ this.free.push(head)
+ }
+ this.head = this.next[head]
+ this.keyMap.delete(k)
+ this.size--
+ return head
+ }
+
+ has(k, { updateAgeOnHas = this.updateAgeOnHas } = {}) {
+ const index = this.keyMap.get(k)
+ if (index !== undefined) {
+ if (!this.isStale(index)) {
+ if (updateAgeOnHas) {
+ this.updateItemAge(index)
+ }
+ return true
+ }
+ }
+ return false
+ }
+
+ // like get(), but without any LRU updating or TTL expiration
+ peek(k, { allowStale = this.allowStale } = {}) {
+ const index = this.keyMap.get(k)
+ if (index !== undefined && (allowStale || !this.isStale(index))) {
+ const v = this.valList[index]
+ // either stale and allowed, or forcing a refresh of non-stale value
+ return this.isBackgroundFetch(v) ? v.__staleWhileFetching : v
+ }
+ }
+
+ backgroundFetch(k, index, options, context) {
+ const v = index === undefined ? undefined : this.valList[index]
+ if (this.isBackgroundFetch(v)) {
+ return v
+ }
+ const ac = new AC()
+ const fetchOpts = {
+ signal: ac.signal,
+ options,
+ context,
+ }
+ const cb = v => {
+ if (!ac.signal.aborted) {
+ this.set(k, v, fetchOpts.options)
+ return v
+ } else {
+ return eb(ac.signal.reason)
+ }
+ }
+ const eb = er => {
+ if (this.valList[index] === p) {
+ // if we allow stale on fetch rejections, then we need to ensure that
+ // the stale value is not removed from the cache when the fetch fails.
+ const noDelete =
+ options.noDeleteOnFetchRejection ||
+ options.allowStaleOnFetchRejection
+ const del = !noDelete || p.__staleWhileFetching === undefined
+ if (del) {
+ this.delete(k)
+ } else {
+ // still replace the *promise* with the stale value,
+ // since we are done with the promise at this point.
+ this.valList[index] = p.__staleWhileFetching
+ }
+ }
+ if (options.allowStaleOnFetchRejection) {
+ return p.__staleWhileFetching
+ } else if (p.__returned === p) {
+ throw er
+ }
+ }
+ const pcall = (res, rej) => {
+ ac.signal.addEventListener('abort', () => res())
+ this.fetchMethod(k, v, fetchOpts).then(res, rej)
+ }
+ const p = new Promise(pcall).then(cb, eb)
+ p.__abortController = ac
+ p.__staleWhileFetching = v
+ p.__returned = null
+ if (index === undefined) {
+ this.set(k, p, fetchOpts.options)
+ index = this.keyMap.get(k)
+ } else {
+ this.valList[index] = p
+ }
+ return p
+ }
+
+ isBackgroundFetch(p) {
+ return (
+ p &&
+ typeof p === 'object' &&
+ typeof p.then === 'function' &&
+ Object.prototype.hasOwnProperty.call(
+ p,
+ '__staleWhileFetching'
+ ) &&
+ Object.prototype.hasOwnProperty.call(p, '__returned') &&
+ (p.__returned === p || p.__returned === null)
+ )
+ }
+
+ // this takes the union of get() and set() opts, because it does both
+ async fetch(
+ k,
+ {
+ // get options
+ allowStale = this.allowStale,
+ updateAgeOnGet = this.updateAgeOnGet,
+ noDeleteOnStaleGet = this.noDeleteOnStaleGet,
+ // set options
+ ttl = this.ttl,
+ noDisposeOnSet = this.noDisposeOnSet,
+ size = 0,
+ sizeCalculation = this.sizeCalculation,
+ noUpdateTTL = this.noUpdateTTL,
+ // fetch exclusive options
+ noDeleteOnFetchRejection = this.noDeleteOnFetchRejection,
+ allowStaleOnFetchRejection = this.allowStaleOnFetchRejection,
+ fetchContext = this.fetchContext,
+ forceRefresh = false,
+ signal,
+ } = {}
+ ) {
+ if (!this.fetchMethod) {
+ return this.get(k, {
+ allowStale,
+ updateAgeOnGet,
+ noDeleteOnStaleGet,
+ })
+ }
+
+ const options = {
+ allowStale,
+ updateAgeOnGet,
+ noDeleteOnStaleGet,
+ ttl,
+ noDisposeOnSet,
+ size,
+ sizeCalculation,
+ noUpdateTTL,
+ noDeleteOnFetchRejection,
+ allowStaleOnFetchRejection,
+ signal,
+ }
+
+ let index = this.keyMap.get(k)
+ if (index === undefined) {
+ const p = this.backgroundFetch(k, index, options, fetchContext)
+ return (p.__returned = p)
+ } else {
+ // in cache, maybe already fetching
+ const v = this.valList[index]
+ if (this.isBackgroundFetch(v)) {
+ return allowStale && v.__staleWhileFetching !== undefined
+ ? v.__staleWhileFetching
+ : (v.__returned = v)
+ }
+
+ // if we force a refresh, that means do NOT serve the cached value,
+ // unless we are already in the process of refreshing the cache.
+ if (!forceRefresh && !this.isStale(index)) {
+ this.moveToTail(index)
+ if (updateAgeOnGet) {
+ this.updateItemAge(index)
+ }
+ return v
+ }
+
+ // ok, it is stale or a forced refresh, and not already fetching.
+ // refresh the cache.
+ const p = this.backgroundFetch(k, index, options, fetchContext)
+ return allowStale && p.__staleWhileFetching !== undefined
+ ? p.__staleWhileFetching
+ : (p.__returned = p)
+ }
+ }
+
+ get(
+ k,
+ {
+ allowStale = this.allowStale,
+ updateAgeOnGet = this.updateAgeOnGet,
+ noDeleteOnStaleGet = this.noDeleteOnStaleGet,
+ } = {}
+ ) {
+ const index = this.keyMap.get(k)
+ if (index !== undefined) {
+ const value = this.valList[index]
+ const fetching = this.isBackgroundFetch(value)
+ if (this.isStale(index)) {
+ // delete only if not an in-flight background fetch
+ if (!fetching) {
+ if (!noDeleteOnStaleGet) {
+ this.delete(k)
+ }
+ return allowStale ? value : undefined
+ } else {
+ return allowStale ? value.__staleWhileFetching : undefined
+ }
+ } else {
+ // if we're currently fetching it, we don't actually have it yet
+ // it's not stale, which means this isn't a staleWhileRefetching,
+ // so we just return undefined
+ if (fetching) {
+ return undefined
+ }
+ this.moveToTail(index)
+ if (updateAgeOnGet) {
+ this.updateItemAge(index)
+ }
+ return value
+ }
+ }
+ }
+
+ connect(p, n) {
+ this.prev[n] = p
+ this.next[p] = n
+ }
+
+ moveToTail(index) {
+ // if tail already, nothing to do
+ // if head, move head to next[index]
+ // else
+ // move next[prev[index]] to next[index] (head has no prev)
+ // move prev[next[index]] to prev[index]
+ // prev[index] = tail
+ // next[tail] = index
+ // tail = index
+ if (index !== this.tail) {
+ if (index === this.head) {
+ this.head = this.next[index]
+ } else {
+ this.connect(this.prev[index], this.next[index])
+ }
+ this.connect(this.tail, index)
+ this.tail = index
+ }
+ }
+
+ get del() {
+ deprecatedMethod('del', 'delete')
+ return this.delete
+ }
+
+ delete(k) {
+ let deleted = false
+ if (this.size !== 0) {
+ const index = this.keyMap.get(k)
+ if (index !== undefined) {
+ deleted = true
+ if (this.size === 1) {
+ this.clear()
+ } else {
+ this.removeItemSize(index)
+ const v = this.valList[index]
+ if (this.isBackgroundFetch(v)) {
+ v.__abortController.abort(new Error('deleted'))
+ } else {
+ this.dispose(v, k, 'delete')
+ if (this.disposeAfter) {
+ this.disposed.push([v, k, 'delete'])
+ }
+ }
+ this.keyMap.delete(k)
+ this.keyList[index] = null
+ this.valList[index] = null
+ if (index === this.tail) {
+ this.tail = this.prev[index]
+ } else if (index === this.head) {
+ this.head = this.next[index]
+ } else {
+ this.next[this.prev[index]] = this.next[index]
+ this.prev[this.next[index]] = this.prev[index]
+ }
+ this.size--
+ this.free.push(index)
+ }
+ }
+ }
+ if (this.disposed) {
+ while (this.disposed.length) {
+ this.disposeAfter(...this.disposed.shift())
+ }
+ }
+ return deleted
+ }
+
+ clear() {
+ for (const index of this.rindexes({ allowStale: true })) {
+ const v = this.valList[index]
+ if (this.isBackgroundFetch(v)) {
+ v.__abortController.abort(new Error('deleted'))
+ } else {
+ const k = this.keyList[index]
+ this.dispose(v, k, 'delete')
+ if (this.disposeAfter) {
+ this.disposed.push([v, k, 'delete'])
+ }
+ }
+ }
+
+ this.keyMap.clear()
+ this.valList.fill(null)
+ this.keyList.fill(null)
+ if (this.ttls) {
+ this.ttls.fill(0)
+ this.starts.fill(0)
+ }
+ if (this.sizes) {
+ this.sizes.fill(0)
+ }
+ this.head = 0
+ this.tail = 0
+ this.initialFill = 1
+ this.free.length = 0
+ this.calculatedSize = 0
+ this.size = 0
+ if (this.disposed) {
+ while (this.disposed.length) {
+ this.disposeAfter(...this.disposed.shift())
+ }
+ }
+ }
+
+ get reset() {
+ deprecatedMethod('reset', 'clear')
+ return this.clear
+ }
+
+ get length() {
+ deprecatedProperty('length', 'size')
+ return this.size
+ }
+
+ static get AbortController() {
+ return AC
+ }
+ static get AbortSignal() {
+ return AS
+ }
+}
+
+export default LRUCache
diff --git a/deps/npm/node_modules/lru-cache/package.json b/deps/npm/node_modules/lru-cache/package.json
index 366ec03dfbc52f..fb90c93901b093 100644
--- a/deps/npm/node_modules/lru-cache/package.json
+++ b/deps/npm/node_modules/lru-cache/package.json
@@ -1,7 +1,7 @@
{
"name": "lru-cache",
"description": "A cache object that deletes the least-recently-used items.",
- "version": "7.14.1",
+ "version": "7.16.2",
"author": "Isaac Z. Schlueter ",
"keywords": [
"mru",
@@ -10,16 +10,36 @@
],
"sideEffects": false,
"scripts": {
- "build": "",
+ "build": "npm run prepare",
+ "pretest": "npm run prepare",
+ "presnap": "npm run prepare",
+ "prepare": "node ./scripts/transpile-to-esm.mjs",
"size": "size-limit",
"test": "tap",
"snap": "tap",
"preversion": "npm test",
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags",
- "format": "prettier --write ."
+ "format": "prettier --write .",
+ "typedoc": "typedoc ./index.d.ts"
+ },
+ "type": "commonjs",
+ "main": "./index.js",
+ "module": "./index.mjs",
+ "types": "./index.d.ts",
+ "exports": {
+ ".": {
+ "import": {
+ "types": "./index.d.ts",
+ "default": "./index.mjs"
+ },
+ "require": {
+ "types": "./index.d.ts",
+ "default": "./index.js"
+ }
+ },
+ "./package.json": "./package.json"
},
- "main": "index.js",
"repository": "git://github.com/isaacs/node-lru-cache.git",
"devDependencies": {
"@size-limit/preset-small-lib": "^7.0.8",
@@ -31,14 +51,16 @@
"eslint-config-prettier": "^8.5.0",
"prettier": "^2.6.2",
"size-limit": "^7.0.8",
- "tap": "^16.0.1",
+ "tap": "^16.3.4",
"ts-node": "^10.7.0",
"tslib": "^2.4.0",
+ "typedoc": "^0.23.24",
"typescript": "^4.6.4"
},
"license": "ISC",
"files": [
"index.js",
+ "index.mjs",
"index.d.ts"
],
"engines": {
diff --git a/deps/npm/node_modules/pacote/lib/fetcher.js b/deps/npm/node_modules/pacote/lib/fetcher.js
index fe5679f00a0a16..4852564d0445d3 100644
--- a/deps/npm/node_modules/pacote/lib/fetcher.js
+++ b/deps/npm/node_modules/pacote/lib/fetcher.js
@@ -425,7 +425,7 @@ class FetcherBase {
return ((mode | m) & ~this.umask) | exe | 0o600
}
- [_tarxOptions] ({ cwd, uid, gid }) {
+ [_tarxOptions] ({ cwd }) {
const sawIgnores = new Set()
return {
cwd,
@@ -460,9 +460,9 @@ class FetcherBase {
log.warn('tar', code, msg)
log.silly('tar', code, msg, data)
},
- uid,
- gid,
umask: this.umask,
+ // always ignore ownership info from tarball metadata
+ preserveOwner: false,
}
}
}
diff --git a/deps/npm/node_modules/pacote/package.json b/deps/npm/node_modules/pacote/package.json
index c09fbda86aa1dd..8a89a1dd612c84 100644
--- a/deps/npm/node_modules/pacote/package.json
+++ b/deps/npm/node_modules/pacote/package.json
@@ -1,6 +1,6 @@
{
"name": "pacote",
- "version": "15.1.0",
+ "version": "15.1.1",
"description": "JavaScript package downloader",
"author": "GitHub Inc.",
"bin": {
diff --git a/deps/npm/package.json b/deps/npm/package.json
index ec375de8794d2e..851d7de8b80134 100644
--- a/deps/npm/package.json
+++ b/deps/npm/package.json
@@ -1,5 +1,5 @@
{
- "version": "9.5.0",
+ "version": "9.5.1",
"name": "npm",
"description": "a package manager for JavaScript",
"workspaces": [
@@ -53,7 +53,7 @@
},
"dependencies": {
"@isaacs/string-locale-compare": "^1.1.0",
- "@npmcli/arborist": "^6.2.2",
+ "@npmcli/arborist": "^6.2.3",
"@npmcli/config": "^6.1.3",
"@npmcli/map-workspaces": "^3.0.2",
"@npmcli/package-json": "^3.0.0",
@@ -76,12 +76,12 @@
"is-cidr": "^4.0.2",
"json-parse-even-better-errors": "^3.0.0",
"libnpmaccess": "^7.0.2",
- "libnpmdiff": "^5.0.10",
- "libnpmexec": "^5.0.10",
- "libnpmfund": "^4.0.10",
+ "libnpmdiff": "^5.0.11",
+ "libnpmexec": "^5.0.11",
+ "libnpmfund": "^4.0.11",
"libnpmhook": "^9.0.3",
"libnpmorg": "^5.0.3",
- "libnpmpack": "^5.0.10",
+ "libnpmpack": "^5.0.11",
"libnpmpublish": "^7.1.0",
"libnpmsearch": "^6.0.2",
"libnpmteam": "^5.0.3",
@@ -102,7 +102,7 @@
"npm-user-validate": "^2.0.0",
"npmlog": "^7.0.1",
"p-map": "^4.0.0",
- "pacote": "^15.1.0",
+ "pacote": "^15.1.1",
"parse-conflict-json": "^3.0.0",
"proc-log": "^3.0.0",
"qrcode-terminal": "^0.12.0",