source: frontend/node_modules/workbox-routing/utils/normalizeHandler.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: 1.2 KB
Line 
1/*
2 Copyright 2018 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 'workbox-core/_private/assert.js';
9import '../_version.js';
10/**
11 * @param {function()|Object} handler Either a function, or an object with a
12 * 'handle' method.
13 * @return {Object} An object with a handle method.
14 *
15 * @private
16 */
17export const normalizeHandler = (handler) => {
18 if (handler && typeof handler === 'object') {
19 if (process.env.NODE_ENV !== 'production') {
20 assert.hasMethod(handler, 'handle', {
21 moduleName: 'workbox-routing',
22 className: 'Route',
23 funcName: 'constructor',
24 paramName: 'handler',
25 });
26 }
27 return handler;
28 }
29 else {
30 if (process.env.NODE_ENV !== 'production') {
31 assert.isType(handler, 'function', {
32 moduleName: 'workbox-routing',
33 className: 'Route',
34 funcName: 'constructor',
35 paramName: 'handler',
36 });
37 }
38 return { handle: handler };
39 }
40};
Note: See TracBrowser for help on using the repository browser.