Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

failure

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

failure - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

20

index.js
'use strict';
var has = Object.prototype.hasOwnProperty;
/**

@@ -13,8 +15,14 @@ * Return an object with all the information that should be in the JSON output.

function toJSON() {
return {
statusCode: this.statusCode,
message: this.message,
stack: this.stack,
type: this.type
};
var obj = { message: this.message, stack: this.stack }, key;
for (key in this) {
if (
has.call(this, key)
&& 'function' !== typeof this[key]
) {
obj[key] = this[key];
}
}
return obj;
}

@@ -21,0 +29,0 @@

{
"name": "failure",
"version": "1.0.0",
"version": "1.1.0",
"description": "Easily generate \"custom\" error objects with addition properties which can be stringfied with JSON.stringify",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -43,3 +43,3 @@ describe('failure', function () {

assume(err.what).equals('why');
assume(res.what).is.undefined();
assume(res.what).is.equals('why');
assume(res.statusCode).equals(200);

@@ -49,2 +49,14 @@ assume(err.statusCode).equals(200);

it('includes properties that were previously specified on a given error', function () {
var err = new Error('fools')
, res;
err.warning = true;
res = failure(err, { what: 'lol' }).toJSON();
assume(res.what).equals('lol');
assume(res.warning).equals(true);
assume(res.message).equals('fools');
});
it('does not override existing toJSON functions', function () {

@@ -51,0 +63,0 @@ var err = new Error('lol');

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc