source: frontend/node_modules/workbox-core/setCacheNameDetails.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 Copyright 2019 Google LLC
3
4 Use of this source code is governed by an MIT-style
5 license that can be found in the LICENSE file or at
6 https://opensource.org/licenses/MIT.
7*/
8import { assert } from './_private/assert.js';
9import { cacheNames } from './_private/cacheNames.js';
10import { WorkboxError } from './_private/WorkboxError.js';
11import './_version.js';
12/**
13 * Modifies the default cache names used by the Workbox packages.
14 * Cache names are generated as `<prefix>-<Cache Name>-<suffix>`.
15 *
16 * @param {Object} details
17 * @param {Object} [details.prefix] The string to add to the beginning of
18 * the precache and runtime cache names.
19 * @param {Object} [details.suffix] The string to add to the end of
20 * the precache and runtime cache names.
21 * @param {Object} [details.precache] The cache name to use for precache
22 * caching.
23 * @param {Object} [details.runtime] The cache name to use for runtime caching.
24 * @param {Object} [details.googleAnalytics] The cache name to use for
25 * `workbox-google-analytics` caching.
26 *
27 * @memberof workbox-core
28 */
29function setCacheNameDetails(details) {
30 if (process.env.NODE_ENV !== 'production') {
31 Object.keys(details).forEach((key) => {
32 assert.isType(details[key], 'string', {
33 moduleName: 'workbox-core',
34 funcName: 'setCacheNameDetails',
35 paramName: `details.${key}`,
36 });
37 });
38 if ('precache' in details && details['precache'].length === 0) {
39 throw new WorkboxError('invalid-cache-name', {
40 cacheNameId: 'precache',
41 value: details['precache'],
42 });
43 }
44 if ('runtime' in details && details['runtime'].length === 0) {
45 throw new WorkboxError('invalid-cache-name', {
46 cacheNameId: 'runtime',
47 value: details['runtime'],
48 });
49 }
50 if ('googleAnalytics' in details &&
51 details['googleAnalytics'].length === 0) {
52 throw new WorkboxError('invalid-cache-name', {
53 cacheNameId: 'googleAnalytics',
54 value: details['googleAnalytics'],
55 });
56 }
57 }
58 cacheNames.updateDetails(details);
59}
60export { setCacheNameDetails };
Note: See TracBrowser for help on using the repository browser.