Skip to content

Commit

Permalink
Use setprototypeof module to replace __proto__ setting
Browse files Browse the repository at this point in the history
closes #11
  • Loading branch information
dougwilson committed May 18, 2016
1 parent d043dca commit fb378a8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ unreleased
==========

* Support new code `421 Misdirected Request`
* Use `setprototypeof` module to replace `__proto__` setting
* deps: statuses@'>= 1.3.0 < 2'
- Add `421 Misdirected Request`
- perf: enable strict mode
Expand Down
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* @private
*/

var setPrototypeOf = require('setprototypeof')
var statuses = require('statuses');
var inherits = require('inherits');

Expand Down Expand Up @@ -118,7 +119,7 @@ function createClientErrorConstructor (HttpError, name, code) {
Error.captureStackTrace(err, ClientError)

// adjust the [[Prototype]]
err.__proto__ = ClientError.prototype
setPrototypeOf(err, ClientError.prototype)

// redefine the error name
Object.defineProperty(err, 'name', {
Expand Down Expand Up @@ -156,7 +157,7 @@ function createServerErrorConstructor (HttpError, name, code) {
Error.captureStackTrace(err, ServerError)

// adjust the [[Prototype]]
err.__proto__ = ServerError.prototype
setPrototypeOf(err, ServerError.prototype)

// redefine the error name
Object.defineProperty(err, 'name', {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"repository": "jshttp/http-errors",
"dependencies": {
"inherits": "2.0.1",
"setprototypeof": "1.0.1",
"statuses": ">= 1.3.0 < 2"
},
"devDependencies": {
Expand Down

0 comments on commit fb378a8

Please sign in to comment.