@@ -20,7 +20,8 @@ export class MiddlewareControl {
20
20
* @private
21
21
* A member holding map of MiddlewareOptions
22
22
*/
23
- private middlewareOptions : Map < string , MiddlewareOptions > ;
23
+ // tslint:disable-next-line:ban-types
24
+ private middlewareOptions : Map < Function , MiddlewareOptions > ;
24
25
25
26
/**
26
27
* @public
@@ -30,31 +31,38 @@ export class MiddlewareControl {
30
31
* @returns The instance of MiddlewareControl
31
32
*/
32
33
public constructor ( middlewareOptions : MiddlewareOptions [ ] = [ ] ) {
33
- this . middlewareOptions = new Map < string , MiddlewareOptions > ( ) ;
34
+ // tslint:disable-next-line:ban-types
35
+ this . middlewareOptions = new Map < Function , MiddlewareOptions > ( ) ;
34
36
for ( const option of middlewareOptions ) {
35
- const name = option . constructor . name ;
36
- this . middlewareOptions . set ( name , option ) ;
37
+ const fn = option . constructor ;
38
+ this . middlewareOptions . set ( fn , option ) ;
37
39
}
38
40
}
39
41
40
42
/**
41
43
* @public
42
- * To get the middleware option using the class name of the option
43
- * @param {string } name - The class name of the strongly typed option class
44
+ * To get the middleware option using the class of the option
45
+ * @param {Function } fn - The class of the strongly typed option class
44
46
* @returns The middleware option
47
+ * @example
48
+ * // if you wanted to return the middleware option associated with this class (MiddlewareControl)
49
+ * // call this function like this:
50
+ * getMiddlewareOptions(MiddlewareControl)
45
51
*/
46
- public getMiddlewareOptions ( name : string ) : MiddlewareOptions {
47
- return this . middlewareOptions . get ( name ) ;
52
+ // tslint:disable-next-line:ban-types
53
+ public getMiddlewareOptions ( fn : Function ) : MiddlewareOptions {
54
+ return this . middlewareOptions . get ( fn ) ;
48
55
}
49
56
50
57
/**
51
58
* @public
52
- * To set the middleware options using the class name of the option
53
- * @param {string } name - The class name of the strongly typed option class
59
+ * To set the middleware options using the class of the option
60
+ * @param {Function } fn - The class of the strongly typed option class
54
61
* @param {MiddlewareOptions } option - The strongly typed middleware option
55
62
* @returns nothing
56
63
*/
57
- public setMiddlewareOptions ( name : string , option : MiddlewareOptions ) : void {
58
- this . middlewareOptions . set ( name , option ) ;
64
+ // tslint:disable-next-line:ban-types
65
+ public setMiddlewareOptions ( fn : Function , option : MiddlewareOptions ) : void {
66
+ this . middlewareOptions . set ( fn , option ) ;
59
67
}
60
68
}
0 commit comments