Skip to content

Commit 329ed49

Browse files
committed
Add docstrings to util functions
1 parent 3ad29d7 commit 329ed49

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

Diff for: src/helpers.ts

+23-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import { StatusDescription } from "./StatusDescription";
44
import { StatusLabel } from "./StatusLabel";
55
import { IHttpResponsesDictionary } from "./Interfaces";
66

7+
/**
8+
* Creates a dictionary containing all HTTP Statuses containing code, phrase and description.
9+
*
10+
* @returns dictionary
11+
*/
712
export const makeHttpResponsesDictionary = () => {
813
let dictionary: IHttpResponsesDictionary = {};
914

@@ -30,13 +35,29 @@ export const makeHttpResponsesDictionary = () => {
3035
return dictionary;
3136
};
3237

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 => {
3447
const httpDictionary = makeHttpResponsesDictionary();
3548

3649
return httpDictionary[code].phrase;
3750
};
3851

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 => {
4061
const httpDictionary = makeHttpResponsesDictionary();
4162

4263
return httpDictionary[code].description;

0 commit comments

Comments
 (0)