UNPKG

@http-status-codes/i18n-ja

Version:
94 lines (93 loc) 4.78 kB
/** * © 2024 aiyoudiao * * このファイルは aiyoudiao によって作成され、多大な努力と知恵が込められています。 * * このファイルを自由に使用、修正、配布できますが、この著作権表示を残してください。 * * このファイルが役に立ったと思ったら、星を付けてくださいまたは私をフォローしてください ツ。 * * 連絡先: * - メール:,newdiao@163.com, * - GitHub:,https://github.com/aiyoudiao, * * プログラミングを楽しんでください!覚えてください、コードは詩で、フロントエンドは芸術です ツ */ import { HttpStatusCode, HttpStatusCodeByCode } from './status-code'; import { HttpStatusText, HttpStatusTextByCode } from './status-text'; /** Key-value mapping of HTTP status codes and HTTP status texts. */ export declare const statusCodeToStatusTextMap: Record<number, string>; /** Key-value mapping of HTTP status codes and HTTP status descriptions. */ export declare const statusCodeToStatusDescriptionMap: Record<number, string>; /** Key-value mapping of HTTP status texts and HTTP status codes. */ export declare const statusTextToStatusCodeMap: Record<string, number>; /** Key-value mapping of HTTP status texts and HTTP status descriptions. */ export declare const statusTextToStatusDescriptionMap: Record<string, string>; export type StatusInfo = { code: number; message: string; success: boolean; }; /** * Returns whether the provided status code or status text is valid or not. * @example isCodeOrTextValid(200) -> true * isCodeOrTextValid('OK') -> true * * @param codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode * @returns yesOrNo: boolean */ export declare function isCodeOrTextValid(codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode): boolean; /** * Returns an object containing information about the provided status code or status text. * @example getStatusInfo(200) -> { code: 200, message: 'OK:The standard response for successful HTTP requests.', success: true} * getStatusInfo('OK') -> { code: 200, message: 'OK:The standard response for successful HTTP requests.', success: true} * * @param codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode * @returns StatusInfo: { code: number, message: string, success: boolean} */ export declare function getStatusInfo(codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode): StatusInfo; /** * Returns whether the provided status code or status text is a successful status or not. * @example isStatusSuccessful(200) -> true * isStatusSuccessful('OK') -> true * isStatusSuccessful(400) -> false * isStatusSuccessful('Bad request') -> false * * @param codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode * @returns successful: boolean */ export declare function isStatusSuccessful(codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode): boolean; /** * Returns a string containing the provided status code and simple message. * @example getSimpleStatusMessage(200) -> 200 OK * getSimpleStatusMessage('OK') -> 200 OK * * @param codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode * @returns simpleStatusMessage: string */ export declare function getSimpleStatusMessage(codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode): string; /** * Returns a string containing the provided status code and message. * @example getStatusMessage(200) -> 200 OK:The standard response for successful HTTP requests. * getStatusMessage('OK') -> 200 OK:The standard response for successful HTTP requests. * * @param codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode * @returns statusMessage: string */ export declare function getStatusMessage(codeOrText: HttpStatusCode | HttpStatusCodeByCode | HttpStatusText | HttpStatusTextByCode): string; /** * Returns the status code for the given http status text. * If the given http status text does not exist, undefined is returned. * @example getStatusCode('OK') -> 200 * @param text: HttpStatusText * @returns statusCode: HttpStatusCode */ export declare function getStatusCode(text: HttpStatusText): HttpStatusCode; /** * Returns the status text for the given http status code. * If the given http status code does not exist, undefined is returned. * @example getStatusCode('200') -> OK * @param code: HttpStatusCode * @returns statusText: HttpStatusText */ export declare function getStatusText(code: HttpStatusCode): string;