http-status-codes
Advanced tools
Comparing version 2.0.0-beta.8 to 2.0.0-beta.9
import { StatusCodes, ReasonPhrases } from './codes'; | ||
/** | ||
* Returns the reason phrase for the given status code. | ||
* If the given status code does not exist, undefined is returned. | ||
* If the given status code does not exist, an error is thrown. | ||
* | ||
* @param {number|string} statusCode The HTTP status code | ||
* @returns {string|undefined} The associated reason phrase (e.g. "Bad Request", "OK") | ||
* @returns {string} The associated reason phrase (e.g. "Bad Request", "OK") | ||
* */ | ||
export declare function getReasonPhrase(statusCode: (number | string)): (string | undefined); | ||
export declare function getReasonPhrase(statusCode: (number | string)): (string); | ||
/** | ||
@@ -15,5 +15,5 @@ * Returns the status code for the given reason phrase. | ||
* @param {string} reasonPhrase The HTTP reason phrase (e.g. "Bad Request", "OK") | ||
* @returns {string|undefined} The associated status code | ||
* @returns {string} The associated status code | ||
* */ | ||
export declare function getStatusCode(reasonPhrase: string): (number | undefined); | ||
export declare function getStatusCode(reasonPhrase: string): (number); | ||
/** | ||
@@ -20,0 +20,0 @@ * @deprecated |
@@ -904,9 +904,13 @@ module.exports = | ||
* Returns the reason phrase for the given status code. | ||
* If the given status code does not exist, undefined is returned. | ||
* If the given status code does not exist, an error is thrown. | ||
* | ||
* @param {number|string} statusCode The HTTP status code | ||
* @returns {string|undefined} The associated reason phrase (e.g. "Bad Request", "OK") | ||
* @returns {string} The associated reason phrase (e.g. "Bad Request", "OK") | ||
* */ | ||
function getReasonPhrase(statusCode) { | ||
return statusCodeToReasonPhrase[statusCode.toString()]; | ||
var result = statusCodeToReasonPhrase[statusCode.toString()]; | ||
if (!result) { | ||
throw new Error("Status code does not exist: " + statusCode); | ||
} | ||
return result; | ||
} | ||
@@ -918,6 +922,10 @@ /** | ||
* @param {string} reasonPhrase The HTTP reason phrase (e.g. "Bad Request", "OK") | ||
* @returns {string|undefined} The associated status code | ||
* @returns {string} The associated status code | ||
* */ | ||
function getStatusCode(reasonPhrase) { | ||
return reasonPhraseToStatusCode[reasonPhrase]; | ||
var result = reasonPhraseToStatusCode[reasonPhrase]; | ||
if (!result) { | ||
throw new Error("Reason phrase does not exist: " + reasonPhrase); | ||
} | ||
return result; | ||
} | ||
@@ -924,0 +932,0 @@ /** |
{ | ||
"name": "http-status-codes", | ||
"version": "2.0.0-beta.8", | ||
"version": "2.0.0-beta.9", | ||
"description": "Constants enumerating the HTTP status codes. Based on the Java Apache HttpStatus API.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
112678
2230