@nxtedition/lib 23.9.9 → 23.9.10

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.
Files changed (2) hide show
  1. package/cache.js +11 -2
  2. package/package.json +1 -1
package/cache.js CHANGED
@@ -77,12 +77,11 @@ export class AsyncCache {
77
77
  if (!promise) {
78
78
  promise = this.#valueSelector(...args).then(
79
79
  (value) => {
80
- this.#dedupe.delete(key)
81
80
  this.set(key, value)
82
81
  return [null, value]
83
82
  },
84
83
  (err) => {
85
- this.#dedupe.delete(key)
84
+ this.delete(key)
86
85
  return [err, null]
87
86
  },
88
87
  )
@@ -114,6 +113,16 @@ export class AsyncCache {
114
113
  }
115
114
 
116
115
  this.#lru.set(key, cached)
116
+ this.#dedupe.delete(key)
117
+ }
118
+
119
+ delete(key) {
120
+ if (typeof key !== 'string' || key.length === 0) {
121
+ throw new TypeError('key must be a non-empty string')
122
+ }
123
+
124
+ this.#lru.delete(key)
125
+ this.#dedupe.delete(key)
117
126
  }
118
127
 
119
128
  clear() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "23.9.9",
3
+ "version": "23.9.10",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",