Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
f6c868d
fix: calculate omit in diff (#8566)
liamcmitchell Sep 23, 2025
4f37534
deps: remove read-package-json-fast
wraithgar Dec 6, 2024
eed8a10
chore: use latest/local arborist in mock-registry
wraithgar Jul 7, 2025
1eedf82
fix: use @npmcli/package-json to parse package.json
wraithgar Jul 7, 2025
ceae674
deps: @npmcli/package-json@7.0.1
wraithgar Sep 17, 2025
1b4433f
deps: @npmcli/map-workspaces@5.0.0
wraithgar Sep 17, 2025
b6bb9ae
deps: pacote@21.0.3
wraithgar Sep 17, 2025
cb36a8a
deps: init-package-json@8.2.2
wraithgar Sep 17, 2025
6b4c5f9
deps: @npmcli/run-script@10.0.0
wraithgar Sep 17, 2025
da81a37
deps: cacache@20.0.1
wraithgar Sep 17, 2025
6221e27
deps: @npmcli/metavuln-calculator@9.0.2
wraithgar Sep 17, 2025
b5bd5e3
deps: npm-profile@12.0.0
wraithgar Sep 17, 2025
1149971
deps: npm-registry-fetch@19.0.0
wraithgar Sep 17, 2025
a2bdecc
deps: sigstore@4.0.0
wraithgar Sep 17, 2025
1f85f94
deps: @sigstore/tuf@4.0.0
wraithgar Sep 17, 2025
66f64eb
deps: make-fetch-happen@15.0.2
wraithgar Sep 17, 2025
633c4ed
deps: hosted-git-info@9.0.0
wraithgar Sep 17, 2025
0082083
deps: normalize-package-data@8.0.0
wraithgar Sep 17, 2025
9392488
deps: npm-package-manifest@11.0.1
wraithgar Sep 17, 2025
bf6b686
deps: npm-package-arg@13.0.0
wraithgar Sep 17, 2025
521823b
deps: @npmcli/git@7.0.0
wraithgar Sep 18, 2025
ea7ca5f
deps: lru-cache@11.2.1
wraithgar Sep 18, 2025
24252a1
deps: @npmcli/agent@4.0.0
wraithgar Sep 18, 2025
38fa2c2
deps: negotiator@1.0.0
wraithgar Sep 18, 2025
79a4e67
deps: minizlib@3.0.2
wraithgar Sep 18, 2025
817f0b1
deps: ignore-walk@8.0.0
wraithgar Sep 18, 2025
1676626
deps: glob@11.0.3
wraithgar Sep 18, 2025
ac33497
deps: mkdirp@3.0.1
wraithgar Sep 18, 2025
566f1b7
deps: minimatch@10.0.3
wraithgar Sep 18, 2025
9f9146f
chore: @tufjs/repo-mock@4.0.0
wraithgar Sep 18, 2025
d4eef14
deps: rimraf@6.0.1
wraithgar Sep 18, 2025
dfd034e
deps: @npmcli/promise-spawn@8.0.3
wraithgar Sep 18, 2025
34bafd1
deps: node-gyp@11.4.2
wraithgar Sep 18, 2025
9519f18
deps: npm-install-checks@7.1.2
wraithgar Sep 18, 2025
6a392f3
deps: tinyglobby@0.2.15
wraithgar Sep 18, 2025
5516583
deps: socks@2.8.7
wraithgar Sep 18, 2025
5f6664b
deps: spdx-license-ids@3.0.22
wraithgar Sep 18, 2025
46035db
deps: debug@4.4.3
wraithgar Sep 18, 2025
c5157c9
deps: chalk@5.6.2
wraithgar Sep 18, 2025
09a7494
deps: supports-color@10.2.2
wraithgar Sep 18, 2025
3b43bf7
chore: dev dependency updates
wraithgar Sep 18, 2025
6e4d673
deps: isexe@3.1.1
wraithgar Sep 18, 2025
099238a
deps: fdir@6.5.0
wraithgar Sep 18, 2025
48285e0
deps: add fdir, isexe, and picomatch to node_modules
wraithgar Sep 18, 2025
402a0ab
chore: @npmcli/template-oss@4.25.1
wraithgar Sep 18, 2025
ef87ec6
deps: diff@8.0.2
wraithgar Sep 18, 2025
6afdda9
chore: ajv-formats@3.0.1
wraithgar Sep 18, 2025
07bf540
deps: is-cidr@6.0.0
wraithgar Sep 18, 2025
0f41bac
deps: tiny-relative-date@2.0.2
wraithgar Sep 18, 2025
05301a4
chore: remark@15.0.1
wraithgar Sep 18, 2025
93d190b
chore: remark-parse@11.0.0
wraithgar Sep 18, 2025
4a46b5a
chore: remark-github@12.0.0
wraithgar Sep 18, 2025
208cb93
chore: remark-gfm@4.0.1
wraithgar Sep 18, 2025
1c6bb4c
chore: rehype-stringify@10.0.1
wraithgar Sep 18, 2025
30fe3ba
chore: remark-man@9.0.0
wraithgar Sep 18, 2025
064deb3
chore: remark-rehype@11.1.2
wraithgar Sep 18, 2025
420a569
chore: unified@11.0.5
wraithgar Sep 18, 2025
0d00fd8
chore: jsdom@27.0.0
wraithgar Sep 18, 2025
ea15731
deps: binary-extensions@3.1.0
wraithgar Sep 23, 2025
4059dfa
chore: properly use arborist and cache in test
owlstronaut Sep 22, 2025
7eb5c09
chore: update package-lock with peer flag fixes
wraithgar Sep 23, 2025
60aa94b
fix: attach path to json parse error
wraithgar Sep 23, 2025
849dcb6
deps: tar@7.5.1 (#8589)
wraithgar Sep 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
deps: lru-cache@11.2.1
  • Loading branch information
wraithgar committed Sep 23, 2025
commit ea7ca5f49d6cab81e9ce3d412963c48acd87b7c0
16 changes: 7 additions & 9 deletions node_modules/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@
!/@npmcli/
/@npmcli/*
!/@npmcli/agent
!/@npmcli/agent/node_modules/
/@npmcli/agent/node_modules/*
!/@npmcli/agent/node_modules/lru-cache
!/@npmcli/fs
!/@npmcli/git
!/@npmcli/git/node_modules/
/@npmcli/git/node_modules/*
!/@npmcli/git/node_modules/lru-cache
!/@npmcli/installed-package-contents
!/@npmcli/map-workspaces
!/@npmcli/map-workspaces/node_modules/
/@npmcli/map-workspaces/node_modules/*
!/@npmcli/map-workspaces/node_modules/glob
!/@npmcli/map-workspaces/node_modules/jackspeak
!/@npmcli/map-workspaces/node_modules/lru-cache
!/@npmcli/map-workspaces/node_modules/minimatch
!/@npmcli/map-workspaces/node_modules/path-scurry
!/@npmcli/metavuln-calculator
Expand All @@ -41,7 +40,6 @@
/@npmcli/package-json/node_modules/*
!/@npmcli/package-json/node_modules/glob
!/@npmcli/package-json/node_modules/jackspeak
!/@npmcli/package-json/node_modules/lru-cache
!/@npmcli/package-json/node_modules/minimatch
!/@npmcli/package-json/node_modules/path-scurry
!/@npmcli/promise-spawn
Expand Down Expand Up @@ -77,7 +75,6 @@
/cacache/node_modules/*
!/cacache/node_modules/glob
!/cacache/node_modules/jackspeak
!/cacache/node_modules/lru-cache
!/cacache/node_modules/minimatch
!/cacache/node_modules/path-scurry
!/chalk
Expand Down Expand Up @@ -108,9 +105,6 @@
!/glob
!/graceful-fs
!/hosted-git-info
!/hosted-git-info/node_modules/
/hosted-git-info/node_modules/*
!/hosted-git-info/node_modules/lru-cache
!/http-cache-semantics
!/http-proxy-agent
!/https-proxy-agent
Expand Down Expand Up @@ -170,6 +164,7 @@
/node-gyp/node_modules/*
!/node-gyp/node_modules/cacache
!/node-gyp/node_modules/chownr
!/node-gyp/node_modules/lru-cache
!/node-gyp/node_modules/make-fetch-happen
!/node-gyp/node_modules/minizlib
!/node-gyp/node_modules/mkdirp
Expand Down Expand Up @@ -210,6 +205,9 @@
!/parse-conflict-json
!/path-key
!/path-scurry
!/path-scurry/node_modules/
/path-scurry/node_modules/*
!/path-scurry/node_modules/lru-cache
!/postcss-selector-parser
!/proc-log
!/proggy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.LRUCache = void 0;
const defaultPerf = (typeof performance === 'object' &&
const perf = typeof performance === 'object' &&
performance &&
typeof performance.now === 'function') ?
performance
typeof performance.now === 'function'
? performance
: Date;
const warned = new Set();
/* c8 ignore start */
const PROCESS = (typeof process === 'object' && !!process ?
process
: {});
const PROCESS = (typeof process === 'object' && !!process ? process : {});
/* c8 ignore start */
const emitWarning = (msg, type, code, fn) => {
typeof PROCESS.emitWarning === 'function' ?
PROCESS.emitWarning(msg, type, code, fn)
typeof PROCESS.emitWarning === 'function'
? PROCESS.emitWarning(msg, type, code, fn)
: console.error(`[${code}] ${type}: ${msg}`);
};
let AC = globalThis.AbortController;
Expand Down Expand Up @@ -81,11 +79,16 @@ const isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n);
// 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
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;
/* c8 ignore stop */
class ZeroArray extends Array {
Expand Down Expand Up @@ -144,17 +147,9 @@ class LRUCache {
#max;
#maxSize;
#dispose;
#onInsert;
#disposeAfter;
#fetchMethod;
#memoMethod;
#perf;
/**
* {@link LRUCache.OptionsBase.perf}
*/
get perf() {
return this.#perf;
}
/**
* {@link LRUCache.OptionsBase.ttl}
*/
Expand Down Expand Up @@ -233,7 +228,6 @@ class LRUCache {
#hasDispose;
#hasFetchMethod;
#hasDisposeAfter;
#hasOnInsert;
/**
* Do not call this method unless you need to inspect the
* inner workings of the cache. If anything returned by this
Expand Down Expand Up @@ -310,26 +304,14 @@ class LRUCache {
get dispose() {
return this.#dispose;
}
/**
* {@link LRUCache.OptionsBase.onInsert} (read-only)
*/
get onInsert() {
return this.#onInsert;
}
/**
* {@link LRUCache.OptionsBase.disposeAfter} (read-only)
*/
get disposeAfter() {
return this.#disposeAfter;
}
constructor(options) {
const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, onInsert, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, perf, } = options;
if (perf !== undefined) {
if (typeof perf?.now !== 'function') {
throw new TypeError('perf option must have a now() method if specified');
}
}
this.#perf = perf ?? defaultPerf;
const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, } = options;
if (max !== 0 && !isPosInt(max)) {
throw new TypeError('max option must be a nonnegative integer');
}
Expand Down Expand Up @@ -373,9 +355,6 @@ class LRUCache {
if (typeof dispose === 'function') {
this.#dispose = dispose;
}
if (typeof onInsert === 'function') {
this.#onInsert = onInsert;
}
if (typeof disposeAfter === 'function') {
this.#disposeAfter = disposeAfter;
this.#disposed = [];
Expand All @@ -385,7 +364,6 @@ class LRUCache {
this.#disposed = undefined;
}
this.#hasDispose = !!this.#dispose;
this.#hasOnInsert = !!this.#onInsert;
this.#hasDisposeAfter = !!this.#disposeAfter;
this.noDisposeOnSet = !!noDisposeOnSet;
this.noUpdateTTL = !!noUpdateTTL;
Expand All @@ -410,8 +388,8 @@ class LRUCache {
this.updateAgeOnGet = !!updateAgeOnGet;
this.updateAgeOnHas = !!updateAgeOnHas;
this.ttlResolution =
isPosInt(ttlResolution) || ttlResolution === 0 ?
ttlResolution
isPosInt(ttlResolution) || ttlResolution === 0
? ttlResolution
: 1;
this.ttlAutopurge = !!ttlAutopurge;
this.ttl = ttl || 0;
Expand Down Expand Up @@ -447,7 +425,7 @@ class LRUCache {
const starts = new ZeroArray(this.#max);
this.#ttls = ttls;
this.#starts = starts;
this.#setItemTTL = (index, ttl, start = this.#perf.now()) => {
this.#setItemTTL = (index, ttl, start = perf.now()) => {
starts[index] = ttl !== 0 ? start : 0;
ttls[index] = ttl;
if (ttl !== 0 && this.ttlAutopurge) {
Expand All @@ -465,7 +443,7 @@ class LRUCache {
}
};
this.#updateItemAge = index => {
starts[index] = ttls[index] !== 0 ? this.#perf.now() : 0;
starts[index] = ttls[index] !== 0 ? perf.now() : 0;
};
this.#statusTTL = (status, index) => {
if (ttls[index]) {
Expand All @@ -485,7 +463,7 @@ class LRUCache {
// that costly call repeatedly.
let cachedNow = 0;
const getNow = () => {
const n = this.#perf.now();
const n = perf.now();
if (this.ttlResolution > 0) {
cachedNow = n;
const t = setTimeout(() => (cachedNow = 0), this.ttlResolution);
Expand Down Expand Up @@ -722,7 +700,9 @@ class LRUCache {
find(fn, getOptions = {}) {
for (const i of this.#indexes()) {
const v = this.#valList[i];
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
const value = this.#isBackgroundFetch(v)
? v.__staleWhileFetching
: v;
if (value === undefined)
continue;
if (fn(value, this.#keyList[i], this)) {
Expand All @@ -744,7 +724,9 @@ class LRUCache {
forEach(fn, thisp = this) {
for (const i of this.#indexes()) {
const v = this.#valList[i];
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
const value = this.#isBackgroundFetch(v)
? v.__staleWhileFetching
: v;
if (value === undefined)
continue;
fn.call(thisp, value, this.#keyList[i], this);
Expand All @@ -757,7 +739,9 @@ class LRUCache {
rforEach(fn, thisp = this) {
for (const i of this.#rindexes()) {
const v = this.#valList[i];
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
const value = this.#isBackgroundFetch(v)
? v.__staleWhileFetching
: v;
if (value === undefined)
continue;
fn.call(thisp, value, this.#keyList[i], this);
Expand Down Expand Up @@ -794,18 +778,17 @@ class LRUCache {
if (i === undefined)
return undefined;
const v = this.#valList[i];
/* c8 ignore start - this isn't tested for the info function,
* but it's the same logic as found in other places. */
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
const value = this.#isBackgroundFetch(v)
? v.__staleWhileFetching
: v;
if (value === undefined)
return undefined;
/* c8 ignore end */
const entry = { value };
if (this.#ttls && this.#starts) {
const ttl = this.#ttls[i];
const start = this.#starts[i];
if (ttl && start) {
const remain = ttl - (this.#perf.now() - start);
const remain = ttl - (perf.now() - start);
entry.ttl = remain;
entry.start = Date.now();
}
Expand All @@ -817,7 +800,7 @@ class LRUCache {
}
/**
* Return an array of [key, {@link LRUCache.Entry}] tuples which can be
* passed to {@link LRUCache#load}.
* passed to {@link LRLUCache#load}.
*
* The `start` fields are calculated relative to a portable `Date.now()`
* timestamp, even if `performance.now()` is available.
Expand All @@ -833,15 +816,17 @@ class LRUCache {
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;
const value = this.#isBackgroundFetch(v)
? v.__staleWhileFetching
: v;
if (value === undefined || key === undefined)
continue;
const entry = { value };
if (this.#ttls && this.#starts) {
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 = this.#perf.now() - this.#starts[i];
const age = perf.now() - this.#starts[i];
entry.start = Math.floor(Date.now() - age);
}
if (this.#sizes) {
Expand Down Expand Up @@ -871,7 +856,7 @@ class LRUCache {
//
// it's ok for this to be a bit slow, it's a rare operation.
const age = Date.now() - entry.start;
entry.start = this.#perf.now() - age;
entry.start = perf.now() - age;
}
this.set(key, entry.value, entry);
}
Expand Down Expand Up @@ -928,9 +913,12 @@ class LRUCache {
let index = this.#size === 0 ? undefined : this.#keyMap.get(k);
if (index === undefined) {
// addition
index = (this.#size === 0 ? this.#tail
: this.#free.length !== 0 ? this.#free.pop()
: this.#size === this.#max ? this.#evict(false)
index = (this.#size === 0
? this.#tail
: this.#free.length !== 0
? this.#free.pop()
: this.#size === this.#max
? this.#evict(false)
: this.#size);
this.#keyList[index] = k;
this.#valList[index] = v;
Expand All @@ -943,9 +931,6 @@ class LRUCache {
if (status)
status.set = 'add';
noUpdateTTL = false;
if (this.#hasOnInsert) {
this.#onInsert?.(v, k, 'add');
}
}
else {
// update
Expand Down Expand Up @@ -977,8 +962,8 @@ class LRUCache {
this.#valList[index] = v;
if (status) {
status.set = 'replace';
const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ?
oldVal.__staleWhileFetching
const oldValue = oldVal && this.#isBackgroundFetch(oldVal)
? oldVal.__staleWhileFetching
: oldVal;
if (oldValue !== undefined)
status.oldValue = oldValue;
Expand All @@ -987,9 +972,6 @@ class LRUCache {
else if (status) {
status.set = 'update';
}
if (this.#hasOnInsert) {
this.onInsert?.(v, k, v === oldVal ? 'update' : 'replace');
}
}
if (ttl !== 0 && !this.#ttls) {
this.#initializeTTLTracking();
Expand Down Expand Up @@ -1172,7 +1154,7 @@ class LRUCache {
const bf = p;
if (this.#valList[index] === p) {
if (v === undefined) {
if (bf.__staleWhileFetching !== undefined) {
if (bf.__staleWhileFetching) {
this.#valList[index] = bf.__staleWhileFetching;
}
else {
Expand Down

Large diffs are not rendered by default.

Loading