feat(planning): grille hebdomadaire complète avec API et filtres

- Connexion API via proxy Angular (résolution CORS, base path /api)
- Import CSS ng-zorro global pour les modales et composants
- Filtres Camion/Show câblés sur l'affichage de la grille
- Camions affichés via TrucksService (linkés au show du même créneau)
- Panneau de détails : spectacles + camions du jour sélectionné
- Modale de création de spectacle stylisée avec fond et centrage
- Positionnement précis des events à la minute dans leur créneau
- Auto-scroll vers l'heure courante au chargement
- Ligne "maintenant" sur la colonne du jour actuel
- Régénération des services OpenAPI (nouveaux noms de types)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-27 20:36:03 +02:00
parent 150b97cd2e
commit 654b297e2e
3131 changed files with 149304 additions and 104334 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
const spawn = require('@npmcli/promise-spawn')
const { promiseRetry } = require('@gar/promise-retry')
const promiseRetry = require('promise-retry')
const { log } = require('proc-log')
const makeError = require('./make-error.js')
const makeOpts = require('./opts.js')
+1 -16
View File
@@ -1,16 +1 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../which/bin/which.js" "$@"
else
exec node "$basedir/../which/bin/which.js" "$@"
fi
../which/bin/which.js
+13 -19
View File
@@ -8,24 +8,18 @@ Windows.
## USAGE
```js
// default export is a minified version that doesn't need to
// load more than one file. Load the 'isexe/raw' export if
// you want the non-minified version for some reason.
import { isexe, sync } from 'isexe'
// or require() works too
// const { isexe } = require('isexe')
isexe('some-file-name').then(
isExe => {
if (isExe) {
console.error('this thing can be run')
} else {
console.error('cannot be run')
}
},
err => {
console.error('probably file doesnt exist or something')
},
)
isexe('some-file-name').then(isExe => {
if (isExe) {
console.error('this thing can be run')
} else {
console.error('cannot be run')
}
}, (err) => {
console.error('probably file doesnt exist or something')
})
// same thing but synchronous, throws errors
isExe = sync('some-file-name')
@@ -72,9 +66,9 @@ The default exported implementation will be chosen based on
import type IsexeOptions from 'isexe'
```
- `ignoreErrors` Treat all errors as "no, this is not
* `ignoreErrors` Treat all errors as "no, this is not
executable", but don't raise them.
- `uid` Number to use as the user id on posix
- `gid` Number to use as the group id on posix
- `pathExt` List of path extensions to use instead of `PATHEXT`
* `uid` Number to use as the user id on posix
* `gid` Number to use as the group id on posix
* `pathExt` List of path extensions to use instead of `PATHEXT`
environment variable on Windows.
+70 -52
View File
@@ -1,78 +1,96 @@
{
"name": "isexe",
"version": "4.0.0",
"version": "3.1.1",
"description": "Minimal module to check if a file is executable.",
"main": "./dist/commonjs/index.min.js",
"module": "./dist/esm/index.min.js",
"types": "./dist/commonjs/index.d.ts",
"main": "./dist/cjs/index.js",
"module": "./dist/mjs/index.js",
"types": "./dist/cjs/index.js",
"files": [
"dist"
],
"tshy": {
"selfLink": false,
"exports": {
"./raw": "./src/index.ts",
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.min.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.min.js"
}
}
}
},
"exports": {
"./raw": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
},
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.min.js"
"types": "./dist/mjs/index.d.ts",
"default": "./dist/mjs/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.min.js"
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
}
}
},
"./posix": {
"import": {
"types": "./dist/mjs/posix.d.ts",
"default": "./dist/mjs/posix.js"
},
"require": {
"types": "./dist/cjs/posix.d.ts",
"default": "./dist/cjs/posix.js"
}
},
"./win32": {
"import": {
"types": "./dist/mjs/win32.d.ts",
"default": "./dist/mjs/win32.js"
},
"require": {
"types": "./dist/cjs/win32.d.ts",
"default": "./dist/cjs/win32.js"
}
},
"./package.json": "./package.json"
},
"devDependencies": {
"@types/node": "^25.2.1",
"esbuild": "^0.27.3",
"prettier": "^3.8.1",
"tap": "^21.5.1",
"tshy": "^3.1.3",
"typedoc": "^0.28.16"
"@types/node": "^20.4.5",
"@types/tap": "^15.0.8",
"c8": "^8.0.1",
"mkdirp": "^0.5.1",
"prettier": "^2.8.8",
"rimraf": "^2.5.0",
"sync-content": "^1.0.2",
"tap": "^16.3.8",
"ts-node": "^10.9.1",
"typedoc": "^0.24.8",
"typescript": "^5.1.6"
},
"scripts": {
"preversion": "npm test",
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags",
"prepare": "tshy && bash build.sh",
"prepare": "tsc -p tsconfig/cjs.json && tsc -p tsconfig/esm.json && bash ./scripts/fixup.sh",
"pretest": "npm run prepare",
"presnap": "npm run prepare",
"test": "tap",
"snap": "tap",
"format": "prettier --write .",
"typedoc": "typedoc"
"test": "c8 tap",
"snap": "c8 tap",
"format": "prettier --write . --loglevel warn --ignore-path ../../.prettierignore --cache",
"typedoc": "typedoc --tsconfig tsconfig/esm.json ./src/*.ts"
},
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
"license": "BlueOak-1.0.0",
"license": "ISC",
"tap": {
"coverage": false,
"node-arg": [
"--enable-source-maps",
"--no-warnings",
"--loader",
"ts-node/esm"
],
"ts": false
},
"prettier": {
"semi": false,
"printWidth": 75,
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"jsxSingleQuote": false,
"bracketSameLine": true,
"arrowParens": "avoid",
"endOfLine": "lf"
},
"repository": "https://github.com/isaacs/isexe",
"engines": {
"node": ">=20"
},
"type": "module"
"node": ">=16"
}
}
+17 -155
View File
@@ -57,17 +57,10 @@ const options = {
// for use when you need to clean up something when objects
// are evicted from the cache
dispose: (value, key, reason) => {
dispose: (value, key) => {
freeFromMemoryOrWhatever(value)
},
// for use when you need to know that an item is being inserted
// note that this does NOT allow you to prevent the insertion,
// it just allows you to know about it.
onInsert: (value, key, reason) => {
logInsertionOrWhatever(key, value)
},
// how long to live in ms
ttl: 1000 * 60 * 5,
@@ -79,7 +72,11 @@ const options = {
// async method to use for cache.fetch(), for
// stale-while-revalidate type of behavior
fetchMethod: async (key, staleValue, { options, signal, context }) => {},
fetchMethod: async (
key,
staleValue,
{ options, signal, context }
) => {},
}
const cache = new LRUCache(options)
@@ -157,7 +154,7 @@ const cache = {
}
cache.timers.set(
k,
setTimeout(() => cache.delete(k), ttl),
setTimeout(() => cache.delete(k), ttl)
)
cache.data.set(k, v)
},
@@ -215,95 +212,9 @@ const myGet = (key, value) => {
}
```
## Tracing and Observability
Most methods can accept a `status` option, which is an
[`LRUCache.Status`](https://isaacs.github.io/node-lru-cache/interfaces/LRUCache.LRUCache.Status.html)
object that will be decorated along the operation with
indications about what was done and why.
Additionally, this library is instrumented using the
[`node:diagnostics_channel`](https://nodejs.org/api/diagnostics_channel.html)
module on Node and other platforms that support it. In order to
get diagnostics metrics, listen on the
`channel('lru-cache:metrics')`. To get Tracing Channel traces,
subscribe to the `tracingChannel('lru-cache')`. The
[`LRUCache.Status`](https://isaacs.github.io/node-lru-cache/interfaces/LRUCache.LRUCache.Status.html)
objects will be provided as the message context to those channel
listeners.
For example, you could do the following to get comprehensive
information about every LRUCache instance in your application:
```ts
import { tracingChannel, subscribe } from 'node:diagnostics_channel'
subscribe('lru-cache:metrics', (message, name) => {
// name will always be 'lru-cache:metrics'
// message will be the LRUCache.Status object for whatever
// synchronous operation was performed.
console.error('LRUCache Metrics', message)
})
tracingChannel('lru-cache').subscribe({
start: status => {
// a traced operation is starting
},
asyncStart: status => {
// an async traced operation is starting
},
asyncEnd: status => {
// an async traced operation is ending
}
error: status => {
// a traced operation failed
},
end: status => {
// a traced operation is complete
},
})
```
The async `cache.fetch()` and `cache.forceFetch` methods are
covered by `tracingChannels`. All the other operations are
covered by the `lru-cache:metrics` channel, because they are
strictly synchronous, and thus don't have an asynchronous
lifecycle to track.
Note that using `status` objects or using
`node:diagnostics_channel` listeners _will_ impose a modest
performance penalty. Creating data objects is not ever free; do
not believe anyone who tells you otherwise. But it is as small as
possible.
### Platform Compatibility Caveat
Not all platforms support the `node:diagnostics_channel` module.
Currently, this is only available in Node, Bun, and Deno, and
some edge computing platforms that provide a Node compatibility
layer.
To work around this, if you are loading in a non-Node
environment, the package.json exports will direct your module
loader to pull in a version that starts out with a dummy
implementation, then does a conditional dynamic `import` of the
`node:diagnostics_channel` module, and then swaps out those
dummy objects with the real thing if it succeeds. This means that
cache metrics and tracing channels started in the first load-time
tick of your application will _not_ be covered, except in
environments that load using the `require` import
condition, or both the `node` and `esm` import conditions
together.
Top-level await _could_ be used to remove this caveat, but that
feature is dead on arrival, unfortunately. See
[#397](https://github.com/isaacs/node-lru-cache/issues/397) and
[#398](https://github.com/isaacs/node-lru-cache/issues/398) for
more details.
## Performance
As of April 2026, version 11 of this library is one of the most
As of January 2022, version 7 of this library is one of the most
performant LRU cache implementations in JavaScript.
Benchmarks can be extremely difficult to get right. In
@@ -358,9 +269,9 @@ If performance matters to you:
LRUCache](https://yomguithereal.github.io/mnemonist/lru-cache)
which uses an Object as its data store.
2. Failing that, if you can use short non-numeric strings (ie,
less than 256 characters) as your keys, and you do not need
any of the other features of this library, use [mnemonist's
2. Failing that, if at all possible, use short non-numeric
strings (ie, less than 256 characters) as your keys, and use
[mnemonist's
LRUCache](https://yomguithereal.github.io/mnemonist/lru-cache).
3. If the types of your keys will be anything else, especially
@@ -372,63 +283,14 @@ If performance matters to you:
(like asynchronous fetching, a variety of TTL staleness
options, and so on), then [mnemonist's
LRUMap](https://yomguithereal.github.io/mnemonist/lru-map) is
also a very good option, and just slightly faster than this
module (since it does considerably less).
a very good option, and just slightly faster than this module
(since it does considerably less).
4. Do not use a `dispose` function, size tracking, or especially
ttl behavior or observability features, unless absolutely
needed. These features are convenient, and necessary in some
use cases, and every attempt has been made to make the
performance impact minimal, but it isn't nothing.
## Testing
When writing tests that involve TTL-related functionality, note
that this module creates an internal reference to the global
`performance` or `Date` objects at import time. If you import it
statically at the top level, those references cannot be mocked or
overridden in your test environment.
To avoid this, dynamically import the package within your tests
so that the references are captured after your mocks are applied.
For example:
```ts
// ❌ Not recommended
import { LRUCache } from 'lru-cache'
// mocking timers, e.g. jest.useFakeTimers()
// ✅ Recommended for TTL tests
// mocking timers, e.g. jest.useFakeTimers()
const { LRUCache } = await import('lru-cache')
```
This ensures that your mocked timers or time sources are
respected when testing TTL behavior.
Additionally, you can pass in a `perf` option when creating your
LRUCache instance. This option accepts any object with a `now`
method that returns a number.
For example, this would be a very bare-bones time-mocking system
you could use in your tests, without any particular test
framework:
```ts
import { LRUCache } from 'lru-cache'
let myClockTime = 0
const cache = new LRUCache<string>({
max: 10,
ttl: 1000,
perf: {
now: () => myClockTime,
},
})
// run tests, updating myClockTime as needed
```
ttl behavior, unless absolutely needed. These features are
convenient, and necessary in some use cases, and every attempt
has been made to make the performance impact minimal, but it
isn't nothing.
## Breaking Changes in Version 7
+33 -156
View File
@@ -1,8 +1,6 @@
/**
* @module LRUCache
*/
import type { Perf } from './perf.js';
export type { Perf } from './perf.js';
declare const TYPE: unique symbol;
export type PosInt = number & {
[TYPE]: 'Positive Integer';
@@ -77,20 +75,6 @@ export declare namespace LRUCache {
* {@link OptionsBase.disposeAfter} options.
*/
type Disposer<K, V> = (value: V, key: K, reason: DisposeReason) => void;
/**
* The reason why an item was added to the cache, passed
* to the {@link Inserter} methods.
*
* - `add`: the item was not found in the cache, and was added
* - `update`: the item was in the cache, with the same value provided
* - `replace`: the item was in the cache, and replaced
*/
type InsertReason = 'add' | 'update' | 'replace';
/**
* A method called upon item insertion, passed as the
* {@link OptionsBase.insert}
*/
type Inserter<K, V> = (value: V, key: K, reason: InsertReason) => void;
/**
* A function that returns the effective calculated size
* of an entry in the cache.
@@ -118,16 +102,8 @@ export declare namespace LRUCache {
*
* The `status` option should be a plain JavaScript object. The following
* fields will be set on it appropriately, depending on the situation.
*
* These objects are also the context objects passed to listeners on the
* `lru-cache:metrics` diagnostic channel, and the `lru-cache` tracing
* channels, in platforms that support them.
*/
interface Status<K, V, FC = unknown> {
/**
* The operation being performed
*/
op?: 'get' | 'set' | 'memo' | 'fetch' | 'delete' | 'has' | 'peek';
interface Status<V> {
/**
* The status of a set() operation.
*
@@ -136,37 +112,7 @@ export declare namespace LRUCache {
* - replace: the item was in the cache, and replaced
* - miss: the item was not added to the cache for some reason
*/
set?: 'add' | 'update' | 'replace' | 'miss' | 'deleted';
/**
* The status of a delete() operation.
*/
delete?: LRUCache.DisposeReason;
/**
* The result of a peek() operation
*
* - hit: the item was found and returned
* - stale: the item is in the cache, but past its ttl and not returned
* - miss: item not in the cache
*/
peek?: 'hit' | 'miss' | 'stale';
/**
* The status of a memo() operation.
*
* - 'hit': the item was found in the cache and returned
* - 'miss': the `memoMethod` function was called
*/
memo?: 'hit' | 'miss';
/**
* The `context` option provided to a memo or fetch operation
*
* In practice, of course, this will be the same type as the `FC`
* fetch context param used to instantiate the LRUCache, but the
* convolutions of threading that through would get quite complicated,
* and preclude forcing/forbidding the passing of a `context` param
* where it is/isn't expected, which is more valuable for error
* prevention.
*/
context?: unknown;
set?: 'add' | 'update' | 'replace' | 'miss';
/**
* the ttl stored for the item, or undefined if ttls are not used.
*/
@@ -197,15 +143,8 @@ export declare namespace LRUCache {
*/
maxEntrySizeExceeded?: true;
/**
* The key that was set or retrieved
*/
key?: K;
/**
* The value that was set
*/
value?: V;
/**
* The old value, specified in the case of `set:'replace'`
* The old value, specified in the case of `set:'update'` or
* `set:'replace'`
*/
oldValue?: V;
/**
@@ -231,10 +170,6 @@ export declare namespace LRUCache {
* {@link FetchOptions.forceRefresh} was specified.
*/
fetch?: 'get' | 'inflight' | 'miss' | 'hit' | 'stale' | 'refresh';
/**
* `forceRefresh` option was used for either a fetch or memo operation
*/
forceRefresh?: boolean;
/**
* The {@link OptionsBase.fetchMethod} was called
*/
@@ -256,7 +191,7 @@ export declare namespace LRUCache {
fetchAborted?: true;
/**
* The abort signal received was ignored, and the fetch was allowed to
* continue in the background.
* continue.
*/
fetchAbortIgnored?: true;
/**
@@ -272,27 +207,15 @@ export declare namespace LRUCache {
*
* - fetching: The item is currently being fetched. If a previous value
* is present and allowed, that will be returned.
* - stale: The item is in the cache, and is stale. If it was returned,
* then the `returnedStale` flag will be set.
* - stale-fetching: The value is being fetched in the background, but is
* currently stale. If the stale value was returned, then the
* `returnedStale` flag will be set.
* - stale: The item is in the cache, and is stale.
* - hit: the item is in the cache
* - miss: the item is not in the cache
*/
get?: 'stale' | 'hit' | 'miss' | 'fetching' | 'stale-fetching';
get?: 'stale' | 'hit' | 'miss';
/**
* A fetch or get operation returned a stale value.
*/
returnedStale?: true;
/**
* A tracingChannel trace was started for this operation
*/
trace?: boolean;
/**
* A reference to the cache instance associated with this operation
*/
cache?: LRUCache<K & {}, V & {}, FC>;
}
/**
* options which override the options set in the LRUCache constructor
@@ -310,7 +233,7 @@ export declare namespace LRUCache {
* the fetchMethod is called.
*/
interface FetcherFetchOptions<K, V, FC = unknown> extends Pick<OptionsBase<K, V, FC>, 'allowStale' | 'updateAgeOnGet' | 'noDeleteOnStaleGet' | 'sizeCalculation' | 'ttl' | 'noDisposeOnSet' | 'noUpdateTTL' | 'noDeleteOnFetchRejection' | 'allowStaleOnFetchRejection' | 'ignoreFetchAbort' | 'allowStaleOnFetchAbort'> {
status?: Status<K, V, FC>;
status?: Status<V>;
size?: Size;
}
/**
@@ -332,7 +255,7 @@ export declare namespace LRUCache {
*/
context?: FC;
signal?: AbortSignal;
status?: Status<K, V, FC>;
status?: Status<V>;
}
/**
* Options provided to {@link LRUCache#fetch} when the FC type is something
@@ -345,7 +268,7 @@ export declare namespace LRUCache {
* Options provided to {@link LRUCache#fetch} when the FC type is
* `undefined` or `void`
*/
interface FetchOptionsNoContext<K, V, FC extends undefined | void = undefined> extends FetchOptions<K, V, FC> {
interface FetchOptionsNoContext<K, V> extends FetchOptions<K, V, undefined> {
context?: undefined;
}
interface MemoOptions<K, V, FC = unknown> extends Pick<OptionsBase<K, V, FC>, 'allowStale' | 'updateAgeOnGet' | 'noDeleteOnStaleGet' | 'sizeCalculation' | 'ttl' | 'noDisposeOnSet' | 'noUpdateTTL' | 'noDeleteOnFetchRejection' | 'allowStaleOnFetchRejection' | 'ignoreFetchAbort' | 'allowStaleOnFetchAbort'> {
@@ -363,7 +286,7 @@ export declare namespace LRUCache {
* be required.
*/
context?: FC;
status?: Status<K, V, FC>;
status?: Status<V>;
}
/**
* Options provided to {@link LRUCache#memo} when the FC type is something
@@ -376,7 +299,7 @@ export declare namespace LRUCache {
* Options provided to {@link LRUCache#memo} when the FC type is
* `undefined` or `void`
*/
interface MemoOptionsNoContext<K, V, FC extends undefined | void = undefined> extends MemoOptions<K, V, FC> {
interface MemoOptionsNoContext<K, V> extends MemoOptions<K, V, undefined> {
context?: undefined;
}
/**
@@ -397,7 +320,7 @@ export declare namespace LRUCache {
*
* This is the union of {@link GetOptions} and {@link SetOptions}, plus
* {@link MemoOptions.forceRefresh}, and
* {@link MemoOptions.context}
* {@link MemoerOptions.context}
*
* Any of these may be modified in the {@link OptionsBase.memoMethod}
* function, but the {@link GetOptions} fields will of course have no
@@ -405,7 +328,7 @@ export declare namespace LRUCache {
* the memoMethod is called.
*/
interface MemoizerMemoOptions<K, V, FC = unknown> extends Pick<OptionsBase<K, V, FC>, 'allowStale' | 'updateAgeOnGet' | 'noDeleteOnStaleGet' | 'sizeCalculation' | 'ttl' | 'noDisposeOnSet' | 'noUpdateTTL'> {
status?: Status<K, V, FC>;
status?: Status<V>;
size?: Size;
start?: Milliseconds;
}
@@ -413,19 +336,18 @@ export declare namespace LRUCache {
* Options that may be passed to the {@link LRUCache#has} method.
*/
interface HasOptions<K, V, FC> extends Pick<OptionsBase<K, V, FC>, 'updateAgeOnHas'> {
status?: Status<K, V, FC>;
status?: Status<V>;
}
/**
* Options that may be passed to the {@link LRUCache#get} method.
*/
interface GetOptions<K, V, FC> extends Pick<OptionsBase<K, V, FC>, 'allowStale' | 'updateAgeOnGet' | 'noDeleteOnStaleGet'> {
status?: Status<K, V, FC>;
status?: Status<V>;
}
/**
* Options that may be passed to the {@link LRUCache#peek} method.
*/
interface PeekOptions<K, V, FC> extends Pick<OptionsBase<K, V, FC>, 'allowStale'> {
status?: Status<K, V, FC>;
}
/**
* Options that may be passed to the {@link LRUCache#set} method.
@@ -446,7 +368,7 @@ export declare namespace LRUCache {
* method is in use.
*/
start?: Milliseconds;
status?: Status<K, V, FC>;
status?: Status<V>;
}
/**
* The type signature for the {@link OptionsBase.fetchMethod} option.
@@ -633,17 +555,6 @@ export declare namespace LRUCache {
* `cache.clear()`, or `cache.set(key, undefined)`.
*/
dispose?: Disposer<K, V>;
/**
* Function that is called when new items are inserted into the cache,
* as `onInsert(value, key, reason)`.
*
* This can be useful if you need to perform actions when an item is
* added, such as logging or tracking insertions.
*
* Unlike some other options, this may _not_ be overridden by passing
* an option to `set()`, for performance and consistency reasons.
*/
onInsert?: Inserter<K, V>;
/**
* The same as {@link OptionsBase.dispose}, but called *after* the entry
* is completely removed and the cache is once again in a clean state.
@@ -699,20 +610,6 @@ export declare namespace LRUCache {
* though for most cases, only minimally.
*/
maxSize?: Size;
/**
* The effective size for background fetch promises.
*
* This has no effect unless `maxSize` and `sizeCalculation` are used,
* and a {@link LRUCache.OptionsBase.fetchMethod} is provided to
* support {@link LRUCache#fetch}.
*
* If a stale value is present in the cache, then the effective size of
* the background fetch is the size of the stale item it will eventually
* replace. If not, then this value is used as its effective size.
*
* @default 1
*/
backgroundFetchSize?: number;
/**
* The maximum allowed size for any single item in the cache.
*
@@ -899,15 +796,6 @@ export declare namespace LRUCache {
* call to {@link LRUCache#fetch}.
*/
ignoreFetchAbort?: boolean;
/**
* In some cases, you may want to swap out the performance/Date object
* used for TTL tracking. This should almost certainly NOT be done in
* production environments!
*
* This value defaults to `global.performance` if it has a `now()` method,
* or the `global.Date` object otherwise.
*/
perf?: Perf;
}
interface OptionsMaxLimit<K, V, FC> extends OptionsBase<K, V, FC> {
max: Count;
@@ -949,12 +837,8 @@ export declare namespace LRUCache {
*
* Changing any of these will alter the defaults for subsequent method calls.
*/
export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
export declare class LRUCache<K extends {}, V extends {}, FC = unknown> implements Map<K, V> {
#private;
/**
* {@link LRUCache.OptionsBase.perf}
*/
get perf(): Perf;
/**
* {@link LRUCache.OptionsBase.ttl}
*/
@@ -1015,8 +899,6 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
* {@link LRUCache.OptionsBase.ignoreFetchAbort}
*/
ignoreFetchAbort: boolean;
/** {@link LRUCache.OptionsBase.backgroundFetchSize} */
backgroundFetchSize: number;
/**
* Do not call this method unless you need to inspect the
* inner workings of the cache. If anything returned by this
@@ -1029,7 +911,6 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
static unsafeExposeInternals<K extends {}, V extends {}, FC extends unknown = unknown>(c: LRUCache<K, V, FC>): {
starts: ZeroArray | undefined;
ttls: ZeroArray | undefined;
autopurgeTimers: (NodeJS.Timeout | undefined)[] | undefined;
sizes: ZeroArray | undefined;
keyMap: Map<K, number>;
keyList: (K | undefined)[];
@@ -1039,8 +920,8 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
readonly head: Index;
readonly tail: Index;
free: StackLike;
isBackgroundFetch: (p: unknown) => p is BackgroundFetch<V>;
backgroundFetch: (k: K, index: number | undefined, options: LRUCache.FetchOptions<K, V, FC>, context: unknown) => BackgroundFetch<V>;
isBackgroundFetch: (p: any) => boolean;
backgroundFetch: (k: K, index: number | undefined, options: LRUCache.FetchOptions<K, V, FC>, context: any) => BackgroundFetch<V>;
moveToTail: (index: number) => void;
indexes: (options?: {
allowStale: boolean;
@@ -1075,10 +956,6 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
* {@link LRUCache.OptionsBase.dispose} (read-only)
*/
get dispose(): LRUCache.Disposer<K, V> | undefined;
/**
* {@link LRUCache.OptionsBase.onInsert} (read-only)
*/
get onInsert(): LRUCache.Inserter<K, V> | undefined;
/**
* {@link LRUCache.OptionsBase.disposeAfter} (read-only)
*/
@@ -1100,7 +977,7 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
* Return a generator yielding `[key, value]` pairs,
* in order from least recently used to most recently used.
*/
rentries(): Generator<(K | V)[], void, unknown>;
rentries(): Generator<(K | V | BackgroundFetch<V> | undefined)[], void, unknown>;
/**
* Return a generator yielding the keys in the cache,
* in order from most recently used to least recently used.
@@ -1124,7 +1001,7 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
* Return a generator yielding the values in the cache,
* in order from least recently used to most recently used.
*/
rvalues(): Generator<V | undefined, void, unknown>;
rvalues(): Generator<V | BackgroundFetch<V> | undefined, void, unknown>;
/**
* Iterating over the cache itself yields the same results as
* {@link LRUCache.entries}
@@ -1152,12 +1029,12 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
*
* Does not update age or recenty of use, or iterate over stale values.
*/
forEach(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => unknown, thisp?: unknown): void;
forEach(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => any, thisp?: any): void;
/**
* The same as {@link LRUCache.forEach} but items are iterated over in
* reverse order. (ie, less recently used items are iterated over first.)
*/
rforEach(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => unknown, thisp?: unknown): void;
rforEach(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => any, thisp?: any): void;
/**
* Delete any stale entries. Returns true if anything was removed,
* false otherwise.
@@ -1178,7 +1055,7 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
info(key: K): LRUCache.Entry<V> | undefined;
/**
* 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.
@@ -1230,7 +1107,7 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
* If the value is `undefined`, then this is an alias for
* `cache.delete(key)`. `undefined` is never stored in the cache.
*/
set(k: K, v: V | undefined, setOptions?: LRUCache.SetOptions<K, V, FC>): this;
set(k: K, v: V | BackgroundFetch<V> | undefined, setOptions?: LRUCache.SetOptions<K, V, FC>): this;
/**
* Evict the least recently used item, returning its value or
* `undefined` if cache is empty.
@@ -1346,23 +1223,23 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
* the same time, because they're both waiting on the same
* underlying fetchMethod response.
*/
fetch(k: K, fetchOptions: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V, FC> : LRUCache.FetchOptionsWithContext<K, V, FC>): Promise<undefined | V>;
fetch(k: unknown extends FC ? K : FC extends undefined | void ? K : never, fetchOptions?: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V, FC> : never): Promise<undefined | V>;
fetch(k: K, fetchOptions: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V> : LRUCache.FetchOptionsWithContext<K, V, FC>): Promise<undefined | V>;
fetch(k: unknown extends FC ? K : FC extends undefined | void ? K : never, fetchOptions?: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V> : never): Promise<undefined | V>;
/**
* In some cases, `cache.fetch()` may resolve to `undefined`, either because
* a {@link LRUCache.OptionsBase#fetchMethod} was not provided (turning
* `cache.fetch(k)` into just an async wrapper around `cache.get(k)`) or
* because `ignoreFetchAbort` was specified (either to the constructor or
* in the {@link LRUCache.FetchOptions}). Also, the
* {@link LRUCache.OptionsBase.fetchMethod} may return `undefined` or `void`, making
* {@link OptionsBase.fetchMethod} may return `undefined` or `void`, making
* the test even more complicated.
*
* Because inferring the cases where `undefined` might be returned are so
* cumbersome, but testing for `undefined` can also be annoying, this method
* can be used, which will reject if `this.fetch()` resolves to undefined.
*/
forceFetch(k: K, fetchOptions: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V, FC> : LRUCache.FetchOptionsWithContext<K, V, FC>): Promise<V>;
forceFetch(k: unknown extends FC ? K : FC extends undefined | void ? K : never, fetchOptions?: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V, FC> : never): Promise<V>;
forceFetch(k: K, fetchOptions: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V> : LRUCache.FetchOptionsWithContext<K, V, FC>): Promise<V>;
forceFetch(k: unknown extends FC ? K : FC extends undefined | void ? K : never, fetchOptions?: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V> : never): Promise<V>;
/**
* If the key is found in the cache, then this is equivalent to
* {@link LRUCache#get}. If not, in the cache, then calculate the value using
@@ -1377,8 +1254,8 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
* relevant in the course of fetching the data. It is only relevant for the
* course of a single `memo()` operation, and discarded afterwards.
*/
memo(k: K, memoOptions: unknown extends FC ? LRUCache.MemoOptions<K, V, FC> : FC extends undefined | void ? LRUCache.MemoOptionsNoContext<K, V, FC> : LRUCache.MemoOptionsWithContext<K, V, FC>): V;
memo(k: unknown extends FC ? K : FC extends undefined | void ? K : never, memoOptions?: unknown extends FC ? LRUCache.MemoOptions<K, V, FC> : FC extends undefined | void ? LRUCache.MemoOptionsNoContext<K, V, FC> : never): V;
memo(k: K, memoOptions: unknown extends FC ? LRUCache.MemoOptions<K, V, FC> : FC extends undefined | void ? LRUCache.MemoOptionsNoContext<K, V> : LRUCache.MemoOptionsWithContext<K, V, FC>): V;
memo(k: unknown extends FC ? K : FC extends undefined | void ? K : never, memoOptions?: unknown extends FC ? LRUCache.MemoOptions<K, V, FC> : FC extends undefined | void ? LRUCache.MemoOptionsNoContext<K, V> : never): V;
/**
* Return a value from the cache. Will update the recency of the cache
* entry found.
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+33 -156
View File
@@ -1,8 +1,6 @@
/**
* @module LRUCache
*/
import type { Perf } from './perf.js';
export type { Perf } from './perf.js';
declare const TYPE: unique symbol;
export type PosInt = number & {
[TYPE]: 'Positive Integer';
@@ -77,20 +75,6 @@ export declare namespace LRUCache {
* {@link OptionsBase.disposeAfter} options.
*/
type Disposer<K, V> = (value: V, key: K, reason: DisposeReason) => void;
/**
* The reason why an item was added to the cache, passed
* to the {@link Inserter} methods.
*
* - `add`: the item was not found in the cache, and was added
* - `update`: the item was in the cache, with the same value provided
* - `replace`: the item was in the cache, and replaced
*/
type InsertReason = 'add' | 'update' | 'replace';
/**
* A method called upon item insertion, passed as the
* {@link OptionsBase.insert}
*/
type Inserter<K, V> = (value: V, key: K, reason: InsertReason) => void;
/**
* A function that returns the effective calculated size
* of an entry in the cache.
@@ -118,16 +102,8 @@ export declare namespace LRUCache {
*
* The `status` option should be a plain JavaScript object. The following
* fields will be set on it appropriately, depending on the situation.
*
* These objects are also the context objects passed to listeners on the
* `lru-cache:metrics` diagnostic channel, and the `lru-cache` tracing
* channels, in platforms that support them.
*/
interface Status<K, V, FC = unknown> {
/**
* The operation being performed
*/
op?: 'get' | 'set' | 'memo' | 'fetch' | 'delete' | 'has' | 'peek';
interface Status<V> {
/**
* The status of a set() operation.
*
@@ -136,37 +112,7 @@ export declare namespace LRUCache {
* - replace: the item was in the cache, and replaced
* - miss: the item was not added to the cache for some reason
*/
set?: 'add' | 'update' | 'replace' | 'miss' | 'deleted';
/**
* The status of a delete() operation.
*/
delete?: LRUCache.DisposeReason;
/**
* The result of a peek() operation
*
* - hit: the item was found and returned
* - stale: the item is in the cache, but past its ttl and not returned
* - miss: item not in the cache
*/
peek?: 'hit' | 'miss' | 'stale';
/**
* The status of a memo() operation.
*
* - 'hit': the item was found in the cache and returned
* - 'miss': the `memoMethod` function was called
*/
memo?: 'hit' | 'miss';
/**
* The `context` option provided to a memo or fetch operation
*
* In practice, of course, this will be the same type as the `FC`
* fetch context param used to instantiate the LRUCache, but the
* convolutions of threading that through would get quite complicated,
* and preclude forcing/forbidding the passing of a `context` param
* where it is/isn't expected, which is more valuable for error
* prevention.
*/
context?: unknown;
set?: 'add' | 'update' | 'replace' | 'miss';
/**
* the ttl stored for the item, or undefined if ttls are not used.
*/
@@ -197,15 +143,8 @@ export declare namespace LRUCache {
*/
maxEntrySizeExceeded?: true;
/**
* The key that was set or retrieved
*/
key?: K;
/**
* The value that was set
*/
value?: V;
/**
* The old value, specified in the case of `set:'replace'`
* The old value, specified in the case of `set:'update'` or
* `set:'replace'`
*/
oldValue?: V;
/**
@@ -231,10 +170,6 @@ export declare namespace LRUCache {
* {@link FetchOptions.forceRefresh} was specified.
*/
fetch?: 'get' | 'inflight' | 'miss' | 'hit' | 'stale' | 'refresh';
/**
* `forceRefresh` option was used for either a fetch or memo operation
*/
forceRefresh?: boolean;
/**
* The {@link OptionsBase.fetchMethod} was called
*/
@@ -256,7 +191,7 @@ export declare namespace LRUCache {
fetchAborted?: true;
/**
* The abort signal received was ignored, and the fetch was allowed to
* continue in the background.
* continue.
*/
fetchAbortIgnored?: true;
/**
@@ -272,27 +207,15 @@ export declare namespace LRUCache {
*
* - fetching: The item is currently being fetched. If a previous value
* is present and allowed, that will be returned.
* - stale: The item is in the cache, and is stale. If it was returned,
* then the `returnedStale` flag will be set.
* - stale-fetching: The value is being fetched in the background, but is
* currently stale. If the stale value was returned, then the
* `returnedStale` flag will be set.
* - stale: The item is in the cache, and is stale.
* - hit: the item is in the cache
* - miss: the item is not in the cache
*/
get?: 'stale' | 'hit' | 'miss' | 'fetching' | 'stale-fetching';
get?: 'stale' | 'hit' | 'miss';
/**
* A fetch or get operation returned a stale value.
*/
returnedStale?: true;
/**
* A tracingChannel trace was started for this operation
*/
trace?: boolean;
/**
* A reference to the cache instance associated with this operation
*/
cache?: LRUCache<K & {}, V & {}, FC>;
}
/**
* options which override the options set in the LRUCache constructor
@@ -310,7 +233,7 @@ export declare namespace LRUCache {
* the fetchMethod is called.
*/
interface FetcherFetchOptions<K, V, FC = unknown> extends Pick<OptionsBase<K, V, FC>, 'allowStale' | 'updateAgeOnGet' | 'noDeleteOnStaleGet' | 'sizeCalculation' | 'ttl' | 'noDisposeOnSet' | 'noUpdateTTL' | 'noDeleteOnFetchRejection' | 'allowStaleOnFetchRejection' | 'ignoreFetchAbort' | 'allowStaleOnFetchAbort'> {
status?: Status<K, V, FC>;
status?: Status<V>;
size?: Size;
}
/**
@@ -332,7 +255,7 @@ export declare namespace LRUCache {
*/
context?: FC;
signal?: AbortSignal;
status?: Status<K, V, FC>;
status?: Status<V>;
}
/**
* Options provided to {@link LRUCache#fetch} when the FC type is something
@@ -345,7 +268,7 @@ export declare namespace LRUCache {
* Options provided to {@link LRUCache#fetch} when the FC type is
* `undefined` or `void`
*/
interface FetchOptionsNoContext<K, V, FC extends undefined | void = undefined> extends FetchOptions<K, V, FC> {
interface FetchOptionsNoContext<K, V> extends FetchOptions<K, V, undefined> {
context?: undefined;
}
interface MemoOptions<K, V, FC = unknown> extends Pick<OptionsBase<K, V, FC>, 'allowStale' | 'updateAgeOnGet' | 'noDeleteOnStaleGet' | 'sizeCalculation' | 'ttl' | 'noDisposeOnSet' | 'noUpdateTTL' | 'noDeleteOnFetchRejection' | 'allowStaleOnFetchRejection' | 'ignoreFetchAbort' | 'allowStaleOnFetchAbort'> {
@@ -363,7 +286,7 @@ export declare namespace LRUCache {
* be required.
*/
context?: FC;
status?: Status<K, V, FC>;
status?: Status<V>;
}
/**
* Options provided to {@link LRUCache#memo} when the FC type is something
@@ -376,7 +299,7 @@ export declare namespace LRUCache {
* Options provided to {@link LRUCache#memo} when the FC type is
* `undefined` or `void`
*/
interface MemoOptionsNoContext<K, V, FC extends undefined | void = undefined> extends MemoOptions<K, V, FC> {
interface MemoOptionsNoContext<K, V> extends MemoOptions<K, V, undefined> {
context?: undefined;
}
/**
@@ -397,7 +320,7 @@ export declare namespace LRUCache {
*
* This is the union of {@link GetOptions} and {@link SetOptions}, plus
* {@link MemoOptions.forceRefresh}, and
* {@link MemoOptions.context}
* {@link MemoerOptions.context}
*
* Any of these may be modified in the {@link OptionsBase.memoMethod}
* function, but the {@link GetOptions} fields will of course have no
@@ -405,7 +328,7 @@ export declare namespace LRUCache {
* the memoMethod is called.
*/
interface MemoizerMemoOptions<K, V, FC = unknown> extends Pick<OptionsBase<K, V, FC>, 'allowStale' | 'updateAgeOnGet' | 'noDeleteOnStaleGet' | 'sizeCalculation' | 'ttl' | 'noDisposeOnSet' | 'noUpdateTTL'> {
status?: Status<K, V, FC>;
status?: Status<V>;
size?: Size;
start?: Milliseconds;
}
@@ -413,19 +336,18 @@ export declare namespace LRUCache {
* Options that may be passed to the {@link LRUCache#has} method.
*/
interface HasOptions<K, V, FC> extends Pick<OptionsBase<K, V, FC>, 'updateAgeOnHas'> {
status?: Status<K, V, FC>;
status?: Status<V>;
}
/**
* Options that may be passed to the {@link LRUCache#get} method.
*/
interface GetOptions<K, V, FC> extends Pick<OptionsBase<K, V, FC>, 'allowStale' | 'updateAgeOnGet' | 'noDeleteOnStaleGet'> {
status?: Status<K, V, FC>;
status?: Status<V>;
}
/**
* Options that may be passed to the {@link LRUCache#peek} method.
*/
interface PeekOptions<K, V, FC> extends Pick<OptionsBase<K, V, FC>, 'allowStale'> {
status?: Status<K, V, FC>;
}
/**
* Options that may be passed to the {@link LRUCache#set} method.
@@ -446,7 +368,7 @@ export declare namespace LRUCache {
* method is in use.
*/
start?: Milliseconds;
status?: Status<K, V, FC>;
status?: Status<V>;
}
/**
* The type signature for the {@link OptionsBase.fetchMethod} option.
@@ -633,17 +555,6 @@ export declare namespace LRUCache {
* `cache.clear()`, or `cache.set(key, undefined)`.
*/
dispose?: Disposer<K, V>;
/**
* Function that is called when new items are inserted into the cache,
* as `onInsert(value, key, reason)`.
*
* This can be useful if you need to perform actions when an item is
* added, such as logging or tracking insertions.
*
* Unlike some other options, this may _not_ be overridden by passing
* an option to `set()`, for performance and consistency reasons.
*/
onInsert?: Inserter<K, V>;
/**
* The same as {@link OptionsBase.dispose}, but called *after* the entry
* is completely removed and the cache is once again in a clean state.
@@ -699,20 +610,6 @@ export declare namespace LRUCache {
* though for most cases, only minimally.
*/
maxSize?: Size;
/**
* The effective size for background fetch promises.
*
* This has no effect unless `maxSize` and `sizeCalculation` are used,
* and a {@link LRUCache.OptionsBase.fetchMethod} is provided to
* support {@link LRUCache#fetch}.
*
* If a stale value is present in the cache, then the effective size of
* the background fetch is the size of the stale item it will eventually
* replace. If not, then this value is used as its effective size.
*
* @default 1
*/
backgroundFetchSize?: number;
/**
* The maximum allowed size for any single item in the cache.
*
@@ -899,15 +796,6 @@ export declare namespace LRUCache {
* call to {@link LRUCache#fetch}.
*/
ignoreFetchAbort?: boolean;
/**
* In some cases, you may want to swap out the performance/Date object
* used for TTL tracking. This should almost certainly NOT be done in
* production environments!
*
* This value defaults to `global.performance` if it has a `now()` method,
* or the `global.Date` object otherwise.
*/
perf?: Perf;
}
interface OptionsMaxLimit<K, V, FC> extends OptionsBase<K, V, FC> {
max: Count;
@@ -949,12 +837,8 @@ export declare namespace LRUCache {
*
* Changing any of these will alter the defaults for subsequent method calls.
*/
export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
export declare class LRUCache<K extends {}, V extends {}, FC = unknown> implements Map<K, V> {
#private;
/**
* {@link LRUCache.OptionsBase.perf}
*/
get perf(): Perf;
/**
* {@link LRUCache.OptionsBase.ttl}
*/
@@ -1015,8 +899,6 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
* {@link LRUCache.OptionsBase.ignoreFetchAbort}
*/
ignoreFetchAbort: boolean;
/** {@link LRUCache.OptionsBase.backgroundFetchSize} */
backgroundFetchSize: number;
/**
* Do not call this method unless you need to inspect the
* inner workings of the cache. If anything returned by this
@@ -1029,7 +911,6 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
static unsafeExposeInternals<K extends {}, V extends {}, FC extends unknown = unknown>(c: LRUCache<K, V, FC>): {
starts: ZeroArray | undefined;
ttls: ZeroArray | undefined;
autopurgeTimers: (NodeJS.Timeout | undefined)[] | undefined;
sizes: ZeroArray | undefined;
keyMap: Map<K, number>;
keyList: (K | undefined)[];
@@ -1039,8 +920,8 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
readonly head: Index;
readonly tail: Index;
free: StackLike;
isBackgroundFetch: (p: unknown) => p is BackgroundFetch<V>;
backgroundFetch: (k: K, index: number | undefined, options: LRUCache.FetchOptions<K, V, FC>, context: unknown) => BackgroundFetch<V>;
isBackgroundFetch: (p: any) => boolean;
backgroundFetch: (k: K, index: number | undefined, options: LRUCache.FetchOptions<K, V, FC>, context: any) => BackgroundFetch<V>;
moveToTail: (index: number) => void;
indexes: (options?: {
allowStale: boolean;
@@ -1075,10 +956,6 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
* {@link LRUCache.OptionsBase.dispose} (read-only)
*/
get dispose(): LRUCache.Disposer<K, V> | undefined;
/**
* {@link LRUCache.OptionsBase.onInsert} (read-only)
*/
get onInsert(): LRUCache.Inserter<K, V> | undefined;
/**
* {@link LRUCache.OptionsBase.disposeAfter} (read-only)
*/
@@ -1100,7 +977,7 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
* Return a generator yielding `[key, value]` pairs,
* in order from least recently used to most recently used.
*/
rentries(): Generator<(K | V)[], void, unknown>;
rentries(): Generator<(K | V | BackgroundFetch<V> | undefined)[], void, unknown>;
/**
* Return a generator yielding the keys in the cache,
* in order from most recently used to least recently used.
@@ -1124,7 +1001,7 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
* Return a generator yielding the values in the cache,
* in order from least recently used to most recently used.
*/
rvalues(): Generator<V | undefined, void, unknown>;
rvalues(): Generator<V | BackgroundFetch<V> | undefined, void, unknown>;
/**
* Iterating over the cache itself yields the same results as
* {@link LRUCache.entries}
@@ -1152,12 +1029,12 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
*
* Does not update age or recenty of use, or iterate over stale values.
*/
forEach(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => unknown, thisp?: unknown): void;
forEach(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => any, thisp?: any): void;
/**
* The same as {@link LRUCache.forEach} but items are iterated over in
* reverse order. (ie, less recently used items are iterated over first.)
*/
rforEach(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => unknown, thisp?: unknown): void;
rforEach(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => any, thisp?: any): void;
/**
* Delete any stale entries. Returns true if anything was removed,
* false otherwise.
@@ -1178,7 +1055,7 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
info(key: K): LRUCache.Entry<V> | undefined;
/**
* 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.
@@ -1230,7 +1107,7 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
* If the value is `undefined`, then this is an alias for
* `cache.delete(key)`. `undefined` is never stored in the cache.
*/
set(k: K, v: V | undefined, setOptions?: LRUCache.SetOptions<K, V, FC>): this;
set(k: K, v: V | BackgroundFetch<V> | undefined, setOptions?: LRUCache.SetOptions<K, V, FC>): this;
/**
* Evict the least recently used item, returning its value or
* `undefined` if cache is empty.
@@ -1346,23 +1223,23 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
* the same time, because they're both waiting on the same
* underlying fetchMethod response.
*/
fetch(k: K, fetchOptions: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V, FC> : LRUCache.FetchOptionsWithContext<K, V, FC>): Promise<undefined | V>;
fetch(k: unknown extends FC ? K : FC extends undefined | void ? K : never, fetchOptions?: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V, FC> : never): Promise<undefined | V>;
fetch(k: K, fetchOptions: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V> : LRUCache.FetchOptionsWithContext<K, V, FC>): Promise<undefined | V>;
fetch(k: unknown extends FC ? K : FC extends undefined | void ? K : never, fetchOptions?: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V> : never): Promise<undefined | V>;
/**
* In some cases, `cache.fetch()` may resolve to `undefined`, either because
* a {@link LRUCache.OptionsBase#fetchMethod} was not provided (turning
* `cache.fetch(k)` into just an async wrapper around `cache.get(k)`) or
* because `ignoreFetchAbort` was specified (either to the constructor or
* in the {@link LRUCache.FetchOptions}). Also, the
* {@link LRUCache.OptionsBase.fetchMethod} may return `undefined` or `void`, making
* {@link OptionsBase.fetchMethod} may return `undefined` or `void`, making
* the test even more complicated.
*
* Because inferring the cases where `undefined` might be returned are so
* cumbersome, but testing for `undefined` can also be annoying, this method
* can be used, which will reject if `this.fetch()` resolves to undefined.
*/
forceFetch(k: K, fetchOptions: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V, FC> : LRUCache.FetchOptionsWithContext<K, V, FC>): Promise<V>;
forceFetch(k: unknown extends FC ? K : FC extends undefined | void ? K : never, fetchOptions?: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V, FC> : never): Promise<V>;
forceFetch(k: K, fetchOptions: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V> : LRUCache.FetchOptionsWithContext<K, V, FC>): Promise<V>;
forceFetch(k: unknown extends FC ? K : FC extends undefined | void ? K : never, fetchOptions?: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V> : never): Promise<V>;
/**
* If the key is found in the cache, then this is equivalent to
* {@link LRUCache#get}. If not, in the cache, then calculate the value using
@@ -1377,8 +1254,8 @@ export declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
* relevant in the course of fetching the data. It is only relevant for the
* course of a single `memo()` operation, and discarded afterwards.
*/
memo(k: K, memoOptions: unknown extends FC ? LRUCache.MemoOptions<K, V, FC> : FC extends undefined | void ? LRUCache.MemoOptionsNoContext<K, V, FC> : LRUCache.MemoOptionsWithContext<K, V, FC>): V;
memo(k: unknown extends FC ? K : FC extends undefined | void ? K : never, memoOptions?: unknown extends FC ? LRUCache.MemoOptions<K, V, FC> : FC extends undefined | void ? LRUCache.MemoOptionsNoContext<K, V, FC> : never): V;
memo(k: K, memoOptions: unknown extends FC ? LRUCache.MemoOptions<K, V, FC> : FC extends undefined | void ? LRUCache.MemoOptionsNoContext<K, V> : LRUCache.MemoOptionsWithContext<K, V, FC>): V;
memo(k: unknown extends FC ? K : FC extends undefined | void ? K : never, memoOptions?: unknown extends FC ? LRUCache.MemoOptions<K, V, FC> : FC extends undefined | void ? LRUCache.MemoOptionsNoContext<K, V> : never): V;
/**
* Return a value from the cache. Will update the recency of the cache
* entry found.
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+44 -82
View File
@@ -1,7 +1,10 @@
{
"name": "lru-cache",
"publishConfig": {
"tag": "legacy-v10"
},
"description": "A cache object that deletes the least-recently-used items.",
"version": "11.5.0",
"version": "10.4.3",
"author": "Isaac Z. Schlueter <i@izs.me>",
"keywords": [
"mru",
@@ -11,7 +14,7 @@
"sideEffects": false,
"scripts": {
"build": "npm run prepare",
"prepare": "tshy && bash scripts/build.sh",
"prepare": "tshy && bash fixup.sh",
"pretest": "npm run prepare",
"presnap": "npm run prepare",
"test": "tap",
@@ -25,130 +28,89 @@
"prebenchmark": "npm run prepare",
"benchmark": "make -C benchmark",
"preprofile": "npm run prepare",
"profile": "make -C benchmark profile",
"lint": "oxlint --fix src test",
"postsnap": "npm run lint",
"postlint": "npm run format"
"profile": "make -C benchmark profile"
},
"main": "./dist/commonjs/index.min.js",
"main": "./dist/commonjs/index.js",
"types": "./dist/commonjs/index.d.ts",
"tshy": {
"esmDialects": [
"browser",
"node"
],
"commonjsDialects": [
"browser",
"node"
],
"exports": {
"./raw": "./src/index.ts",
".": {
".": "./src/index.ts",
"./min": {
"import": {
"browser": {
"types": "./dist/esm/browser/index.d.ts",
"default": "./dist/esm/browser/index.min.js"
},
"node": {
"types": "./dist/esm/node/index.d.ts",
"default": "./dist/esm/node/index.min.js"
},
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.min.js"
},
"require": {
"browser": {
"types": "./dist/commonjs/browser/index.d.ts",
"default": "./dist/commonjs/browser/index.min.js"
},
"node": {
"types": "./dist/commonjs/node/index.d.ts",
"default": "./dist/commonjs/node/index.min.js"
},
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.min.js"
}
}
},
"selfLink": false
}
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/isaacs/node-lru-cache.git"
"url": "git://github.com/isaacs/node-lru-cache.git"
},
"devDependencies": {
"@types/node": "^20.2.5",
"@types/tap": "^15.0.6",
"benchmark": "^2.1.4",
"esbuild": "^0.28.0",
"esbuild": "^0.17.11",
"eslint-config-prettier": "^8.5.0",
"marked": "^4.2.12",
"mkdirp": "^3.0.1",
"oxlint": "^1.65.0",
"oxlint-tsgolint": "^0.22.1",
"prettier": "^3.8.3",
"tap": "^21.7.4",
"tshy": "^4.1.2",
"typedoc": "^0.28.19"
"mkdirp": "^2.1.5",
"prettier": "^2.6.2",
"tap": "^20.0.3",
"tshy": "^2.0.0",
"tslib": "^2.4.0",
"typedoc": "^0.25.3",
"typescript": "^5.2.2"
},
"license": "BlueOak-1.0.0",
"license": "ISC",
"files": [
"dist"
],
"engines": {
"node": "20 || >=22"
"prettier": {
"semi": false,
"printWidth": 70,
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"jsxSingleQuote": false,
"bracketSameLine": true,
"arrowParens": "avoid",
"endOfLine": "lf"
},
"tap": {
"node-arg": [
"--expose-gc"
],
"plugin": [
"@tapjs/clock"
]
},
"exports": {
"./raw": {
".": {
"import": {
"browser": {
"types": "./dist/esm/browser/index.d.ts",
"default": "./dist/esm/browser/index.js"
},
"node": {
"types": "./dist/esm/node/index.d.ts",
"default": "./dist/esm/node/index.js"
},
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"browser": {
"types": "./dist/commonjs/browser/index.d.ts",
"default": "./dist/commonjs/browser/index.js"
},
"node": {
"types": "./dist/commonjs/node/index.d.ts",
"default": "./dist/commonjs/node/index.js"
},
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
},
".": {
"./min": {
"import": {
"browser": {
"types": "./dist/esm/browser/index.d.ts",
"default": "./dist/esm/browser/index.min.js"
},
"node": {
"types": "./dist/esm/node/index.d.ts",
"default": "./dist/esm/node/index.min.js"
},
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.min.js"
},
"require": {
"browser": {
"types": "./dist/commonjs/browser/index.d.ts",
"default": "./dist/commonjs/browser/index.min.js"
},
"node": {
"types": "./dist/commonjs/node/index.d.ts",
"default": "./dist/commonjs/node/index.min.js"
},
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.min.js"
}
}
},
"type": "module",
"module": "./dist/esm/index.min.js"
"module": "./dist/esm/index.js"
}
+6 -6
View File
@@ -2,7 +2,7 @@
"author": "GitHub Inc.",
"name": "which",
"description": "Like which(1) unix command. Find the first instance of an executable in the PATH.",
"version": "6.0.1",
"version": "5.0.0",
"repository": {
"type": "git",
"url": "git+https://github.com/npm/node-which.git"
@@ -13,11 +13,11 @@
},
"license": "ISC",
"dependencies": {
"isexe": "^4.0.0"
"isexe": "^3.1.1"
},
"devDependencies": {
"@npmcli/eslint-config": "^6.0.0",
"@npmcli/template-oss": "4.28.1",
"@npmcli/eslint-config": "^5.0.0",
"@npmcli/template-oss": "4.23.3",
"tap": "^16.3.0"
},
"scripts": {
@@ -42,11 +42,11 @@
]
},
"engines": {
"node": "^20.17.0 || >=22.9.0"
"node": "^18.17.0 || >=20.5.0"
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.28.1",
"version": "4.23.3",
"publish": "true"
}
}
+10 -10
View File
@@ -1,6 +1,6 @@
{
"name": "@npmcli/git",
"version": "7.0.2",
"version": "6.0.3",
"main": "lib/index.js",
"files": [
"bin/",
@@ -33,22 +33,22 @@
"devDependencies": {
"@npmcli/eslint-config": "^5.0.0",
"@npmcli/template-oss": "4.24.1",
"npm-package-arg": "^13.0.0",
"npm-package-arg": "^12.0.1",
"slash": "^3.0.0",
"tap": "^16.0.1"
},
"dependencies": {
"@gar/promise-retry": "^1.0.0",
"@npmcli/promise-spawn": "^9.0.0",
"ini": "^6.0.0",
"lru-cache": "^11.2.1",
"npm-pick-manifest": "^11.0.1",
"proc-log": "^6.0.0",
"@npmcli/promise-spawn": "^8.0.0",
"ini": "^5.0.0",
"lru-cache": "^10.0.1",
"npm-pick-manifest": "^10.0.0",
"proc-log": "^5.0.0",
"promise-retry": "^2.0.1",
"semver": "^7.3.5",
"which": "^6.0.0"
"which": "^5.0.0"
},
"engines": {
"node": "^20.17.0 || >=22.9.0"
"node": "^18.17.0 || >=20.5.0"
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",