@nxtedition/cache 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -96,9 +96,9 @@ Same as `get()` but does **not** trigger a refresh on cache miss. Returns `{ val
96
96
 
97
97
  Triggers a fetch via `valueSelector` regardless of cache state. If a fetch for the same key is already in-flight (from a prior `get()` or `refresh()`), the existing promise is returned instead of starting a new one.
98
98
 
99
- #### `cache.delete(key): void`
99
+ #### `cache.delete(...args): void`
100
100
 
101
- Remove a key from the cache. Also cancels any in-flight deduplication for that key, meaning a pending fetch will not write its result to the cache.
101
+ Remove an entry from the cache. The cache key is derived from `args` via the `keySelector`, just like `get()` and `refresh()`. Also cancels any in-flight deduplication for that key, meaning a pending fetch will not write its result to the cache.
102
102
 
103
103
  #### `cache.purgeStale(): void`
104
104
 
package/lib/index.d.ts CHANGED
@@ -28,7 +28,7 @@ export declare class AsyncCache<V = unknown, A extends unknown[] = unknown[]> {
28
28
  get(...args: A): CacheResult<V>;
29
29
  peek(...args: A): CacheResult<V>;
30
30
  refresh(...args: A): Promise<V>;
31
- delete(key: string): void;
31
+ delete(...args: A): void;
32
32
  purgeStale(): void;
33
33
  }
34
34
  export {};
package/lib/index.js CHANGED
@@ -196,8 +196,8 @@ export class AsyncCache {
196
196
  return this.#refresh(args)
197
197
  }
198
198
 
199
- delete(key ) {
200
- this.#delete(key)
199
+ delete(...args ) {
200
+ this.#delete(args)
201
201
  }
202
202
 
203
203
  purgeStale() {
@@ -268,7 +268,7 @@ export class AsyncCache {
268
268
  : { value: promise, async: true }
269
269
  }
270
270
 
271
- #refresh(args , key = this.#keySelector(...args)) {
271
+ #refresh(args , key = this.#keySelector(...args)) {
272
272
  if (typeof key !== 'string' || key.length === 0) {
273
273
  throw new TypeError('keySelector must return a non-empty string')
274
274
  }
@@ -350,7 +350,7 @@ export class AsyncCache {
350
350
  }
351
351
  }
352
352
 
353
- #delete(key ) {
353
+ #delete(args , key = this.#keySelector(...args)) {
354
354
  if (typeof key !== 'string' || key.length === 0) {
355
355
  throw new TypeError('key must be a non-empty string')
356
356
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/cache",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -31,5 +31,5 @@
31
31
  "dependencies": {
32
32
  "lru-cache": "^11.2.6"
33
33
  },
34
- "gitHead": "5c8b45723e68c527888e75a1536569479da7e4c5"
34
+ "gitHead": "a113680af7f36b0262a5de692bbf57409a51b86b"
35
35
  }