File tree 1 file changed +23
-2
lines changed
1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,11 @@ import { StatusDescription } from "./StatusDescription";
4
4
import { StatusLabel } from "./StatusLabel" ;
5
5
import { IHttpResponsesDictionary } from "./Interfaces" ;
6
6
7
+ /**
8
+ * Creates a dictionary containing all HTTP Statuses containing code, phrase and description.
9
+ *
10
+ * @returns dictionary
11
+ */
7
12
export const makeHttpResponsesDictionary = ( ) => {
8
13
let dictionary : IHttpResponsesDictionary = { } ;
9
14
@@ -30,13 +35,29 @@ export const makeHttpResponsesDictionary = () => {
30
35
return dictionary ;
31
36
} ;
32
37
33
- export const getStatusPhraseByCode = ( code : number ) : StatusPhrase => {
38
+ /**
39
+ * Get a status phrase from a given HTTP Status code
40
+ *
41
+ * @param code {StatusCode|number}
42
+ * @returns {string }
43
+ */
44
+ export const getStatusPhraseByCode = (
45
+ code : number | StatusCode
46
+ ) : StatusPhrase => {
34
47
const httpDictionary = makeHttpResponsesDictionary ( ) ;
35
48
36
49
return httpDictionary [ code ] . phrase ;
37
50
} ;
38
51
39
- export const getStatusDescriptionByCode = ( code : number ) : StatusDescription => {
52
+ /**
53
+ * Get a description from a given HTTP Status code
54
+ *
55
+ * @param code {StatusCode|number}
56
+ * @returns {string }
57
+ */
58
+ export const getStatusDescriptionByCode = (
59
+ code : number | StatusCode
60
+ ) : StatusDescription => {
40
61
const httpDictionary = makeHttpResponsesDictionary ( ) ;
41
62
42
63
return httpDictionary [ code ] . description ;
You can’t perform that action at this time.
0 commit comments