-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.min.js
1 lines (1 loc) · 4.98 KB
/
index.min.js
1
let httpStatuses=Symbol();export default class{getReason(statusCode){let code=this.guardInvalidCode(statusCode);return this[httpStatuses][code]}isSuccess(statusCode){let code=parseInt(statusCode,10);return code>=200&&code<=299}constructor(){this[httpStatuses]={};this.code={};this[httpStatuses][this.code.CONTINUE=100]="Continue";this[httpStatuses][this.code.SWITCHING_PROTOCOLS=101]="Switching Protocols";this[httpStatuses][this.code.PROCESSING=102]="Processing";this[httpStatuses][this.code.CHECKPOINT=103]="Checkpoint";this[httpStatuses][this.code.OK=200]="OK";this[httpStatuses][this.code.CREATED=201]="Created";this[httpStatuses][this.code.ACCEPTED=202]="Accepted";this[httpStatuses][this.code.NON_AUTHORITATIVE_INFORMATION=203]="Non-Authoritative Information";this[httpStatuses][this.code.NO_CONTENT=204]="No Content";this[httpStatuses][this.code.RESET_CONTENT=205]="Reset Content";this[httpStatuses][this.code.PARTIAL_CONTENT=206]="Partial Content";this[httpStatuses][this.code.PARTIAL_UPDATE_OK=207]="Partial Update OK";this[httpStatuses][this.code.MULTI_STATUS=207]="Multi-Status";this[httpStatuses][this.code.ALREADY_REPORTED=208]="Already Reported";this[httpStatuses][this.code.IM_USED=226]="Instance-Manipulation Used";this[httpStatuses][this.code.MULTIPLE_CHOICES=300]="Multiple Choices";this[httpStatuses][this.code.MOVED_PERMANENTLY=301]="Moved Permanently";this[httpStatuses][this.code.FOUND=302]="Found (Moved Temporarily)";this[httpStatuses][this.code.SEE_OTHER=303]="See Other";this[httpStatuses][this.code.NOT_MODIFIED=304]="Not Modified";this[httpStatuses][this.code.USE_PROXY=305]="Use Proxy";this[httpStatuses][this.code.TEMPORARY_REDIRECT=307]="Temporary Redirect";this[httpStatuses][this.code.PERMANENT_REDIRECT=308]="Permanent Redirect";this[httpStatuses][this.code.BAD_REQUEST=400]="Bad Request";this[httpStatuses][this.code.UNAUTHORIZED=401]="Unauthorized";this[httpStatuses][this.code.PAYMENT_REQUIRED=402]="Payment Required";this[httpStatuses][this.code.FORBIDDEN=403]="Forbidden";this[httpStatuses][this.code.NOT_FOUND=404]="Not Found";this[httpStatuses][this.code.METHOD_NOT_ALLOWED=405]="Method Not Allowed";this[httpStatuses][this.code.NOT_ACCEPTABLE=406]="Not Acceptable";this[httpStatuses][this.code.PROXY_AUTHENTICATION_REQUIRED=407]="Proxy Authentication Required";this[httpStatuses][this.code.REQUEST_TIMEOUT=408]="Request Timeout";this[httpStatuses][this.code.CONFLICT=409]="Conflict";this[httpStatuses][this.code.GONE=410]="Gone";this[httpStatuses][this.code.LENGTH_REQUIRED=411]="Length Required";this[httpStatuses][this.code.PRECONDITION_FAILED=412]="Precondition Failed";this[httpStatuses][this.code.PAYLOAD_TOO_LARGE=413]="Payload Too Large";this[httpStatuses][this.code.URI_TOO_LONG=414]="URI Too Long";this[httpStatuses][this.code.UNSUPPORTED_MEDIA_TYPE=415]="Unsupported Media Type";this[httpStatuses][this.code.RANGE_NOT_SATISFIABLE=416]="Range Not Satisfiable";this[httpStatuses][this.code.EXPECTATION_FAILED=417]="Expectation Failed";this[httpStatuses][this.code.I_AM_A_TEAPOT=418]="I'm A Teapot";this[httpStatuses][this.code.MISDIRECTED_REQUEST=421]="Misdirected Request";this[httpStatuses][this.code.UNPROCESSABLE_ENTITY=422]="Unprocessable Entity";this[httpStatuses][this.code.LOCKED=423]="Locked";this[httpStatuses][this.code.FAILED_DEPENDENCY=424]="Failed Dependency";this[httpStatuses][this.code.UPGRADE_REQUIRED=426]="Upgrade Required";this[httpStatuses][this.code.PRECONDITION_REQUIRED=428]="Precondition Required";this[httpStatuses][this.code.TOO_MANY_REQUESTS=429]="Too Many Requests";this[httpStatuses][this.code.REQUEST_HEADER_FIELDS_TOO_LARGE=431]="Request Header Fields Too Large";this[httpStatuses][this.code.UNAVAILABLE_FOR_LEGAL_REASONS=451]="Unavailable for Legal Reasons";this[httpStatuses][this.code.INTERNAL_SERVER_ERROR=500]="Internal Server Error";this[httpStatuses][this.code.NOT_IMPLEMENTED=501]="Not Implemented";this[httpStatuses][this.code.BAD_GATEWAY=502]="Bad Gateway";this[httpStatuses][this.code.SERVICE_UNAVAILABLE=503]="Service Unavailable";this[httpStatuses][this.code.GATEWAY_TIMEOUT=504]="Gateway Timeout";this[httpStatuses][this.code.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP Version Not Supported";this[httpStatuses][this.code.VARIANT_ALSO_NEGOTIATES=506]="Variant Also Negotiates";this[httpStatuses][this.code.INSUFFICIENT_STORAGE=507]="Insufficient Storage";this[httpStatuses][this.code.LOOP_DETECTED=508]="Loop Detected";this[httpStatuses][this.code.BANDWIDTH_LIMIT_EXCEEDED=509]="Bandwidth Limit Exceeded";this[httpStatuses][this.code.NOT_EXTENDED=510]="Not Extended";this[httpStatuses][this.code.NETWORK_AUTHENTICATION_REQUIRED=511]="Network Authentication Required";this[httpStatuses][this.code.NETWORK_CONNECT_TIMEOUT_ERROR=599]="Network Connect Timeout Error"}guardInvalidCode(statusCode){let code=parseInt(statusCode,10);if(code!=statusCode){throw new Error('Status code "'+code+'" is invalid.')}if(code===306){throw new Error('Status code "'+code+'" is explicitly reserved but not used.')}if(!this[httpStatuses].hasOwnProperty(""+code)){throw new Error('Status code "'+code+'" is unassigned.')}return code}};