http-info
TypeScript icon, indicating that this package has built-in type declarations

1.2.3 • Public • Published

HTTP Info

HTTP Status Codes Utility

Build Status npm version JavaScript Style Guide MIT license

A set of utility that allow to match, convert and list HTTP status codes.

Complete list of HTTP Status Codes can be found here.

Installation

$ npm install http-info

Usage

import httpInfo from 'http-info'
 
// Convert
httpInfo.convert(100) // => Continue
 
// Match
httpInfo.match.redirection(300) // => true
 
// List
httpInfo.list.serverError // => [500, 501, 502, 504, 505, 506, 507, 508, 510, 511]

API

convert(code)

Convert any HTTP code to its status message.

Code

type number

Return

string | null

Example
httpInfo.convert(100) // => Continue
httpInfo.convert(301) // => Moved Permanently
 
// False value will return null
httpInfo.convert(600) // => null

match[<group>](code)

Returns whether an HTTP code exists in the specified group.

Group

informational, success, redirection, clientError, serverError, _any

Code

type number

Return

boolean

Example
httpInfo.match.clientError(404) // => true
httpInfo.match.success(500) // => false
 
// To check for all groups, use `_any`
httpInfo.match._any(100) // => true

list[<group>]

Group

informational, success, redirection, clientError, serverError

Return

array

Example
httpInfo.list.success // => [200, 201, 202, ...]
httpInfo.list.serverError // ==> [500, 501, 502, ...]

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i http-info

Weekly Downloads

0

Version

1.2.3

License

MIT

Unpacked Size

11.5 kB

Total Files

16

Last publish

Collaborators

  • veronq