File tree Expand file tree Collapse file tree 1 file changed +1
-16
lines changed Expand file tree Collapse file tree 1 file changed +1
-16
lines changed Original file line number Diff line number Diff line change @@ -5,42 +5,27 @@ export class HttpContextToken<ValueT> {
5
5
export class HttpContext {
6
6
private readonly map = new Map < HttpContextToken < unknown > , unknown > ( ) ;
7
7
8
- /**
9
- * Store a value in the context. If a value is already present it will be overwritten.
10
- */
11
8
set < T > ( token : HttpContextToken < T > , value : T ) : HttpContext {
12
9
this . map . set ( token , value ) ;
13
10
return this ;
14
11
}
15
12
16
- /**
17
- * Retrieve the value associated with the given token.
18
- */
19
13
get < T > ( token : HttpContextToken < T > ) : T | undefined {
20
14
if ( ! this . map . has ( token ) ) {
21
- this . map . set ( token , token . defaultValue ) ;
15
+ return token . defaultValue ;
22
16
}
23
17
return this . map . get ( token ) as T ;
24
18
}
25
19
26
- /**
27
- * Delete the value associated with the given token.
28
- */
29
20
delete ( token : HttpContextToken < unknown > ) : HttpContext {
30
21
this . map . delete ( token ) ;
31
22
return this ;
32
23
}
33
24
34
- /**
35
- * Checks for existence of a given token.
36
- */
37
25
has ( token : HttpContextToken < unknown > ) : boolean {
38
26
return this . map . has ( token ) ;
39
27
}
40
28
41
- /**
42
- * @returns a list of tokens currently stored in the context.
43
- */
44
29
keys ( ) : IterableIterator < HttpContextToken < unknown > > {
45
30
return this . map . keys ( ) ;
46
31
}
You can’t perform that action at this time.
0 commit comments