source: frontend/node_modules/workbox-routing/src/utils/normalizeHandler.ts

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 2 weeks 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*/
8
9import {assert} from 'workbox-core/_private/assert.js';
10import {RouteHandler, RouteHandlerObject} from 'workbox-core/types.js';
11
12import '../_version.js';
13
14/**
15 * @param {function()|Object} handler Either a function, or an object with a
16 * 'handle' method.
17 * @return {Object} An object with a handle method.
18 *
19 * @private
20 */
21export const normalizeHandler = (handler: RouteHandler): RouteHandlerObject => {
22 if (handler && typeof handler === 'object') {
23 if (process.env.NODE_ENV !== 'production') {
24 assert!.hasMethod(handler, 'handle', {
25 moduleName: 'workbox-routing',
26 className: 'Route',
27 funcName: 'constructor',
28 paramName: 'handler',
29 });
30 }
31 return handler;
32 } else {
33 if (process.env.NODE_ENV !== 'production') {
34 assert!.isType(handler, 'function', {
35 moduleName: 'workbox-routing',
36 className: 'Route',
37 funcName: 'constructor',
38 paramName: 'handler',
39 });
40 }
41 return {handle: handler};
42 }
43};
Note: See TracBrowser for help on using the repository browser.