UNPKG

2.33 kBJavaScriptView Raw
1"use strict";
2/**
3 * -------------------------------------------------------------------------------------------
4 * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
5 * See License in the project root for license information.
6 * -------------------------------------------------------------------------------------------
7 */
8Object.defineProperty(exports, "__esModule", { value: true });
9exports.MiddlewareControl = void 0;
10/**
11 * @class
12 * Class representing MiddlewareControl
13 */
14var MiddlewareControl = /** @class */ (function () {
15 /**
16 * @public
17 * @constructor
18 * Creates an instance of MiddlewareControl
19 * @param {MiddlewareOptions[]} [middlewareOptions = []] - The array of middlewareOptions
20 * @returns The instance of MiddlewareControl
21 */
22 function MiddlewareControl(middlewareOptions) {
23 if (middlewareOptions === void 0) { middlewareOptions = []; }
24 this.middlewareOptions = new Map();
25 for (var _i = 0, middlewareOptions_1 = middlewareOptions; _i < middlewareOptions_1.length; _i++) {
26 var option = middlewareOptions_1[_i];
27 var fn = option.constructor;
28 this.middlewareOptions.set(fn, option);
29 }
30 }
31 /**
32 * @public
33 * To get the middleware option using the class of the option
34 * @param {Function} fn - The class of the strongly typed option class
35 * @returns The middleware option
36 * @example
37 * // if you wanted to return the middleware option associated with this class (MiddlewareControl)
38 * // call this function like this:
39 * getMiddlewareOptions(MiddlewareControl)
40 */
41 MiddlewareControl.prototype.getMiddlewareOptions = function (fn) {
42 return this.middlewareOptions.get(fn);
43 };
44 /**
45 * @public
46 * To set the middleware options using the class of the option
47 * @param {Function} fn - The class of the strongly typed option class
48 * @param {MiddlewareOptions} option - The strongly typed middleware option
49 * @returns nothing
50 */
51 MiddlewareControl.prototype.setMiddlewareOptions = function (fn, option) {
52 this.middlewareOptions.set(fn, option);
53 };
54 return MiddlewareControl;
55}());
56exports.MiddlewareControl = MiddlewareControl;
57//# sourceMappingURL=MiddlewareControl.js.map
\No newline at end of file