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 |
|
31 | module.exports = function cacheEntryStale(cache, cacheKey) {
|
32 | if (!(cache instanceof Cache))
|
33 | throw new TypeError(
|
34 | typeof process === 'object' && process.env.NODE_ENV !== 'production'
|
35 | ? 'Argument 1 `cache` must be a `Cache` instance.'
|
36 | : createArgErrorMessageProd(1)
|
37 | );
|
38 |
|
39 | if (typeof cacheKey !== 'string')
|
40 | throw new TypeError(
|
41 | typeof process === 'object' && process.env.NODE_ENV !== 'production'
|
42 | ? 'Argument 2 `cacheKey` must be a string.'
|
43 | : createArgErrorMessageProd(2)
|
44 | );
|
45 |
|
46 | if (!(cacheKey in cache.store))
|
47 | throw new Error(`Cache key \`${cacheKey}\` isn’t in the store.`);
|
48 |
|
49 | cache.dispatchEvent(new CustomEvent(`${cacheKey}/stale`));
|
50 | };
|