http-errors
Advanced tools
Comparing version 1.8.1 to 2.0.0
@@ -0,1 +1,16 @@ | ||
2.0.0 / 2021-12-17 | ||
================== | ||
* Drop support for Node.js 0.6 | ||
* Remove `I'mateapot` export; use `ImATeapot` instead | ||
* Remove support for status being non-first argument | ||
* Rename `UnorderedCollection` constructor to `TooEarly` | ||
* deps: depd@2.0.0 | ||
- Replace internal `eval` usage with `Function` constructor | ||
- Use instance methods on `process` to check for listeners | ||
* deps: statuses@2.0.1 | ||
- Fix messaging casing of `418 I'm a Teapot` | ||
- Remove code 306 | ||
- Rename `425 Unordered Collection` to standard `425 Too Early` | ||
2021-11-14 / 1.8.1 | ||
@@ -2,0 +17,0 @@ ================== |
40
index.js
@@ -57,21 +57,15 @@ /*! | ||
var arg = arguments[i] | ||
if (arg instanceof Error) { | ||
var type = typeof arg | ||
if (type === 'object' && arg instanceof Error) { | ||
err = arg | ||
status = err.status || err.statusCode || status | ||
continue | ||
} else if (type === 'number' && i === 0) { | ||
status = arg | ||
} else if (type === 'string') { | ||
msg = arg | ||
} else if (type === 'object') { | ||
props = arg | ||
} else { | ||
throw new TypeError('argument #' + (i + 1) + ' unsupported type ' + type) | ||
} | ||
switch (typeof arg) { | ||
case 'string': | ||
msg = arg | ||
break | ||
case 'number': | ||
status = arg | ||
if (i !== 0) { | ||
deprecate('non-first-argument status code; replace with createError(' + arg + ', ...)') | ||
} | ||
break | ||
case 'object': | ||
props = arg | ||
break | ||
} | ||
} | ||
@@ -84,3 +78,3 @@ | ||
if (typeof status !== 'number' || | ||
(!statuses[status] && (status < 400 || status >= 600))) { | ||
(!statuses.message[status] && (status < 400 || status >= 600))) { | ||
status = 500 | ||
@@ -96,3 +90,3 @@ } | ||
? new HttpError(msg) | ||
: new Error(msg || statuses[status]) | ||
: new Error(msg || statuses.message[status]) | ||
Error.captureStackTrace(err, createError) | ||
@@ -141,3 +135,3 @@ } | ||
// create the error object | ||
var msg = message != null ? message : statuses[code] | ||
var msg = message != null ? message : statuses.message[code] | ||
var err = new Error(msg) | ||
@@ -211,3 +205,3 @@ | ||
// create the error object | ||
var msg = message != null ? message : statuses[code] | ||
var msg = message != null ? message : statuses.message[code] | ||
var err = new Error(msg) | ||
@@ -272,3 +266,3 @@ | ||
var CodeError | ||
var name = toIdentifier(statuses[code]) | ||
var name = toIdentifier(statuses.message[code]) | ||
@@ -290,6 +284,2 @@ switch (codeClass(code)) { | ||
}) | ||
// backwards-compatibility | ||
exports["I'mateapot"] = deprecate.function(exports.ImATeapot, | ||
'"I\'mateapot"; use "ImATeapot" instead') | ||
} | ||
@@ -296,0 +286,0 @@ |
{ | ||
"name": "http-errors", | ||
"description": "Create HTTP error objects", | ||
"version": "1.8.1", | ||
"version": "2.0.0", | ||
"author": "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)", | ||
@@ -13,6 +13,6 @@ "contributors": [ | ||
"dependencies": { | ||
"depd": "~1.1.2", | ||
"depd": "2.0.0", | ||
"inherits": "2.0.4", | ||
"setprototypeof": "1.2.0", | ||
"statuses": ">= 1.5.0 < 2", | ||
"statuses": "2.0.1", | ||
"toidentifier": "1.0.1" | ||
@@ -26,3 +26,3 @@ }, | ||
"eslint-plugin-node": "11.1.0", | ||
"eslint-plugin-promise": "5.1.1", | ||
"eslint-plugin-promise": "5.2.0", | ||
"eslint-plugin-standard": "4.1.0", | ||
@@ -33,3 +33,3 @@ "mocha": "9.1.3", | ||
"engines": { | ||
"node": ">= 0.6" | ||
"node": ">= 0.8" | ||
}, | ||
@@ -40,3 +40,4 @@ "scripts": { | ||
"test-ci": "nyc --reporter=lcov --reporter=text npm test", | ||
"test-cov": "nyc --reporter=html --reporter=text npm test" | ||
"test-cov": "nyc --reporter=html --reporter=text npm test", | ||
"version": "node scripts/version-history.js && git add HISTORY.md" | ||
}, | ||
@@ -43,0 +44,0 @@ "keywords": [ |
@@ -17,3 +17,3 @@ # http-errors | ||
```bash | ||
```console | ||
$ npm install http-errors | ||
@@ -137,3 +137,3 @@ ``` | ||
|424 |FailedDependency | | ||
|425 |UnorderedCollection | | ||
|425 |TooEarly | | ||
|426 |UpgradeRequired | | ||
@@ -140,0 +140,0 @@ |428 |PreconditionRequired | |
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
18808
233
+ Addeddepd@2.0.0(transitive)
+ Addedstatuses@2.0.1(transitive)
- Removeddepd@1.1.2(transitive)
- Removedstatuses@1.5.0(transitive)
Updateddepd@2.0.0
Updatedstatuses@2.0.1