standard-http-error
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -0,1 +1,6 @@ | ||
## 1.1.0 (May 21, 2015) | ||
- Adds support for use in the browser by adding a cached copy of status codes. | ||
For example, use StandardHttpError.js with | ||
[Browserify](https://github.com/substack/node-browserify). | ||
## 1.0.1 (Feb 23, 2015) | ||
@@ -2,0 +7,0 @@ - Fixes subclassing example in README. |
14
index.js
@@ -0,5 +1,5 @@ | ||
exports = module.exports = HttpError | ||
var StandardError = require("standard-error") | ||
var STATUS_CODE_TO_NAME = require("http").STATUS_CODES | ||
var STATUS_NAME_TO_CODE = require("http-codes") | ||
module.exports = HttpError | ||
var STATUS_CODE_TO_NAME = require("./codes") | ||
var STATUS_NAME_TO_CODE = exports | ||
@@ -18,4 +18,2 @@ function HttpError(code, msg, props) { | ||
assign(HttpError, STATUS_NAME_TO_CODE) | ||
Object.defineProperties(HttpError.prototype, { | ||
@@ -40,5 +38,5 @@ statusCode: alias("code"), | ||
function assign(target, source) { | ||
for (var key in source) target[key] = source[key] | ||
return target | ||
for (var code in STATUS_CODE_TO_NAME) { | ||
var name = STATUS_CODE_TO_NAME[code] | ||
exports[name.replace("'", "").replace(/[- ]/g, "_").toUpperCase()] = +code | ||
} | ||
@@ -45,0 +43,0 @@ |
{ | ||
"name": "standard-http-error", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Standard HTTP error class. Proper serialization, no bloat. Extensible.", | ||
@@ -33,4 +33,7 @@ "keywords": [ | ||
"browser": { | ||
"./codes.js": "./codes.json" | ||
}, | ||
"dependencies": { | ||
"http-codes": ">= 1.0.0 < 2", | ||
"standard-error": ">= 1.1.0 < 2" | ||
@@ -42,4 +45,5 @@ }, | ||
"must": ">= 0.12.0 < 0.13", | ||
"objectware": ">= 1.6.0 < 2" | ||
"oolong": ">= 1.7.0 < 2", | ||
"http-codes": ">= 1.0.0 < 2" | ||
} | ||
} |
@@ -156,5 +156,5 @@ StandardHttpError.js | ||
The names are generated automatically from Node.js's `Http.STATUS_CODES` object | ||
during run-time, so they'll always be up to date. Here's the list for reference | ||
as of Node v0.11: | ||
When running on Node.js, the names are generated during run-time from | ||
`Http.STATUS_CODES`, so they'll always be up to date. Here's the list for | ||
reference as of Node v0.12: | ||
@@ -161,0 +161,0 @@ Code | Name |
@@ -1,2 +0,2 @@ | ||
var Ow = require("objectware") | ||
var $ = require("oolong") | ||
var STATUS_NAMES = require("http-codes") | ||
@@ -161,3 +161,3 @@ var HttpError = require("..") | ||
Ow.each(STATUS_NAMES, function(code, constant) { | ||
$.each(STATUS_NAMES, function(code, constant) { | ||
it("must have " + constant + " equal " + code, function() { | ||
@@ -164,0 +164,0 @@ HttpError[constant].must.equal(code) |
Sorry, the diff of this file is not supported yet
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
19434
1
12
249
4
- Removedhttp-codes@>= 1.0.0 < 2
- Removedhttp-codes@1.0.0(transitive)