@js-thing/http-status-codes
Version:
Contains properly documented HTTP status code enums, reason phrases and helpers as defined in RFC
55 lines • 2.39 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isInformationStatus = exports.isInformationReasonPhrase = exports.is1xxInformationStatusCode = exports.isInformationStatusCode = void 0;
var HttpStatusCodes_1 = require("../HttpStatusCodes");
var HttpReasonPhrases_1 = require("../HttpReasonPhrases");
/**
* Checks whether the status code belongs to `HttpInformationStatusCodes` enum.
* The range is all standard code between [100 - 199]
*
* To check the entire 1xx range use `is1xxInformationStatusCode(code: number)` instead.
* @param statusCode - The integer status code. e.g. 100
* @returns `true` if matches `false` otherwise
*/
var isInformationStatusCode = function (statusCode) {
return HttpStatusCodes_1.HttpInformationStatusCodes[statusCode] !== undefined;
};
exports.isInformationStatusCode = isInformationStatusCode;
/**
* Checks whether the status code belongs to 1xx family of status codes.
*
* @param statusCode - The integer status code. e.g. 100
* @returns `true` if matches `false` otherwise
*/
var is1xxInformationStatusCode = function (statusCode) {
return statusCode >= 100 && statusCode <= 199;
};
exports.is1xxInformationStatusCode = is1xxInformationStatusCode;
/**
* Checks whether the input string belongs to `HttpInformationReasonPhrases` enum.
*
* The match is case sensitive
*
* @param reasonPhrase - The reason phrase. e.g. 'Ok'
* @returns `true` if matches `false` otherwise
*/
var isInformationReasonPhrase = function (reasonPhrase) {
return Object.values(HttpReasonPhrases_1.HttpInformationReasonPhrases).includes(reasonPhrase) === true;
};
exports.isInformationReasonPhrase = isInformationReasonPhrase;
/**
* Checks whether the input integer or string belongs to
* `HttpInformationStatusCodes` or `HttpInformationReasonPhrases` enum.
* For integer input, the range is all standard code between [100 - 199].
* For string input, the match is case sensitive.
*
* To check the entire 1xx range use `is1xxInformationStatusCode(code: number)` instead.
* @param status - e.g. 'Ok' or 200
* @returns `true` if matches `false` otherwise
*/
var isInformationStatus = function (status) {
return exports.isInformationStatusCode(status) ||
exports.isInformationReasonPhrase(status);
};
exports.isInformationStatus = isInformationStatus;
//# sourceMappingURL=isInformationStatus.js.map