Comparing version 2.0.0 to 2.0.1
@@ -0,1 +1,6 @@ | ||
2.0.1 / 2021-01-03 | ||
================== | ||
* Fix returning values from `Object.prototype` | ||
2.0.0 / 2020-04-19 | ||
@@ -2,0 +7,0 @@ ================== |
38
index.js
@@ -89,2 +89,30 @@ /*! | ||
/** | ||
* Get the status code for given message. | ||
* @private | ||
*/ | ||
function getStatusCode (message) { | ||
var msg = message.toLowerCase() | ||
if (!Object.prototype.hasOwnProperty.call(status.code, msg)) { | ||
throw new Error('invalid status message: "' + message + '"') | ||
} | ||
return status.code[msg] | ||
} | ||
/** | ||
* Get the status message for given code. | ||
* @private | ||
*/ | ||
function getStatusMessage (code) { | ||
if (!Object.prototype.hasOwnProperty.call(status.message, code)) { | ||
throw new Error('invalid status code: ' + code) | ||
} | ||
return status.message[code] | ||
} | ||
/** | ||
* Get the status code. | ||
@@ -105,4 +133,3 @@ * | ||
if (typeof code === 'number') { | ||
if (!status.message[code]) throw new Error('invalid status code: ' + code) | ||
return status.message[code] | ||
return getStatusMessage(code) | ||
} | ||
@@ -117,9 +144,6 @@ | ||
if (!isNaN(n)) { | ||
if (!status.message[n]) throw new Error('invalid status code: ' + n) | ||
return status.message[n] | ||
return getStatusMessage(n) | ||
} | ||
n = status.code[code.toLowerCase()] | ||
if (!n) throw new Error('invalid status message: "' + code + '"') | ||
return n | ||
return getStatusCode(code) | ||
} |
{ | ||
"name": "statuses", | ||
"description": "HTTP status utility", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"contributors": [ | ||
@@ -23,12 +23,12 @@ "Douglas Christopher Wilson <doug@somethingdoug.com>", | ||
"devDependencies": { | ||
"csv-parse": "4.8.8", | ||
"eslint": "6.8.0", | ||
"csv-parse": "4.14.2", | ||
"eslint": "7.17.0", | ||
"eslint-config-standard": "14.1.1", | ||
"eslint-plugin-import": "2.20.2", | ||
"eslint-plugin-import": "2.22.1", | ||
"eslint-plugin-markdown": "1.0.2", | ||
"eslint-plugin-node": "11.1.0", | ||
"eslint-plugin-promise": "4.2.1", | ||
"eslint-plugin-standard": "4.0.1", | ||
"mocha": "7.1.1", | ||
"nyc": "15.0.1", | ||
"eslint-plugin-standard": "4.1.0", | ||
"mocha": "8.2.1", | ||
"nyc": "15.1.0", | ||
"raw-body": "2.4.1", | ||
@@ -45,3 +45,3 @@ "stream-to-array": "2.3.0" | ||
"test": "mocha --reporter spec --check-leaks --bail test/", | ||
"test-ci": "nyc --reporter=text npm test", | ||
"test-ci": "nyc --reporter=lcov --reporter=text npm test", | ||
"test-cov": "nyc --reporter=html --reporter=text npm test", | ||
@@ -48,0 +48,0 @@ "update": "npm run fetch && npm run build", |
@@ -6,3 +6,3 @@ # statuses | ||
[![Node.js Version][node-version-image]][node-version-url] | ||
[![Build Status][travis-image]][travis-url] | ||
[![Build Status][ci-image]][ci-url] | ||
[![Test Coverage][coveralls-image]][coveralls-url] | ||
@@ -129,2 +129,4 @@ | ||
[ci-image]: https://badgen.net/github/checks/jshttp/statuses/master?label=ci | ||
[ci-url]: https://github.com/jshttp/statuses/actions?query=workflow%3Aci | ||
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/statuses/master | ||
@@ -137,3 +139,1 @@ [coveralls-url]: https://coveralls.io/r/jshttp/statuses?branch=master | ||
[npm-version-image]: https://badgen.net/npm/v/statuses | ||
[travis-image]: https://badgen.net/travis/jshttp/statuses/master | ||
[travis-url]: https://travis-ci.org/jshttp/statuses |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12116
181