1.2.3 • Published 5 years ago

http-info v1.2.3

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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[\](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

informational, success, redirection, clientError, serverError

Return

array

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

License

MIT

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago