1 | 'use strict';
|
2 |
|
3 | const createArgErrorMessageProd = require('../private/createArgErrorMessageProd');
|
4 | const Cache = require('./Cache');
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | module.exports = function cacheEntryDelete(cache, cacheKey) {
|
31 | if (!(cache instanceof Cache))
|
32 | throw new TypeError(
|
33 | typeof process === 'object' && process.env.NODE_ENV !== 'production'
|
34 | ? 'Argument 1 `cache` must be a `Cache` instance.'
|
35 | : createArgErrorMessageProd(1)
|
36 | );
|
37 |
|
38 | if (typeof cacheKey !== 'string')
|
39 | throw new TypeError(
|
40 | typeof process === 'object' && process.env.NODE_ENV !== 'production'
|
41 | ? 'Argument 2 `cacheKey` must be a string.'
|
42 | : createArgErrorMessageProd(2)
|
43 | );
|
44 |
|
45 | if (cacheKey in cache.store) {
|
46 | delete cache.store[cacheKey];
|
47 |
|
48 | cache.dispatchEvent(new CustomEvent(`${cacheKey}/delete`));
|
49 | }
|
50 | };
|