* Make jsunity hash function avoid recursion This guards against traversals of recursive data structures causing a stack overflow. This is crucial when using assertEqual with unknown inputs. * Update deps accepts: 1.3.4 -> 1.3.5 ansi_up: 2.0.2 -> 4.0.3 content-disposition: 0.5.2 -> 0.5.3 dedent: 0.6.0 -> 0.7.0 error-stack-parser: 1.3.6 -> 2.0.2 eslint: 2.13.1 -> 5.16.0 eslint-config-semistandard: 6.0.2 -> removed eslint-config-standard: 5.3.1 -> removed eslint-plugin-promise: 1.3.2 -> removed eslint-plugin-standard: 1.3.2 -> removed highlight.js: 9.12.0 -> 9.15.6 http-errors: 1.6.2 -> 1.7.2 iconv-lite: 0.4.19 -> 0.4.24 joi: 9.2.0 -> 14.3.1 joi-to-json-schema: 2.3.0 -> 4.0.1 js-yaml: 3.10.0 -> 3.13.1 marked: 0.3.9 -> 0.6.2 mime-types: 2.1.12 -> 2.1.22 mocha: 2.5.3 -> 6.1.3 qs: 6.5.1 -> 6.7.0 semver: 5.4.1 -> 6.0.0 statuses: 1.4.0 -> 1.5.0 timezone: 1.0.13 -> 1.0.22 type-is: 1.6.15 -> 1.6.16 underscore: 1.8.3 -> 1.9.1 * Inline eslint semistandard config The eslint standard config has become extremely opinionated and incompatible with the existing coding style. This subset matches the existing coding style most closely. In the future we should migrate to an autoformatter like prettier and avoid this problem altogether. * Linting * Fix mocha runner * New joi has additional property |
||
---|---|---|
.. | ||
HISTORY.md | ||
LICENSE | ||
README.md | ||
codes.json | ||
index.js | ||
package.json |
README.md
Statuses
HTTP status utility for node.
This module provides a list of status codes and messages sourced from a few different projects:
Installation
This is a Node.js module available through the
npm registry. Installation is done using the
npm install
command:
$ npm install statuses
API
var status = require('statuses')
var code = status(Integer || String)
If Integer
or String
is a valid HTTP code or status message, then the
appropriate code
will be returned. Otherwise, an error will be thrown.
status(403) // => 403
status('403') // => 403
status('forbidden') // => 403
status('Forbidden') // => 403
status(306) // throws, as it's not supported by node.js
status.STATUS_CODES
Returns an object which maps status codes to status messages, in the same format as the Node.js http module.
status.codes
Returns an array of all the status codes as Integer
s.
var msg = status[code]
Map of code
to status message
. undefined
for invalid code
s.
status[404] // => 'Not Found'
var code = status[msg]
Map of status message
to code
. msg
can either be title-cased or
lower-cased. undefined
for invalid status message
s.
status['not found'] // => 404
status['Not Found'] // => 404
status.redirect[code]
Returns true
if a status code is a valid redirect status.
status.redirect[200] // => undefined
status.redirect[301] // => true
status.empty[code]
Returns true
if a status code expects an empty body.
status.empty[200] // => undefined
status.empty[204] // => true
status.empty[304] // => true
status.retry[code]
Returns true
if you should retry the rest.
status.retry[501] // => undefined
status.retry[503] // => true