-
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathcacheEntryDelete.mjs
More file actions
25 lines (19 loc) · 747 Bytes
/
cacheEntryDelete.mjs
File metadata and controls
25 lines (19 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// @ts-check
/** @import { CacheEventMap, CacheKey } from "./Cache.mjs" */
import Cache from "./Cache.mjs";
/**
* Deletes a {@link Cache.store cache store} entry, dispatching the
* {@linkcode Cache} event {@link CacheEventMap.delete `delete`}.
* @param {Cache} cache Cache to update.
* @param {CacheKey} cacheKey Cache key.
*/
export default function cacheEntryDelete(cache, cacheKey) {
if (!(cache instanceof Cache))
throw new TypeError("Argument 1 `cache` must be a `Cache` instance.");
if (typeof cacheKey !== "string")
throw new TypeError("Argument 2 `cacheKey` must be a string.");
if (cacheKey in cache.store) {
delete cache.store[cacheKey];
cache.dispatchEvent(new CustomEvent(`${cacheKey}/delete`));
}
}