Socket
Socket
Sign inDemoInstall

es6-error

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es6-error - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

test/index.js

41

dist/index.js

@@ -1,29 +0,35 @@

"use strict";
'use strict';
var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, '__esModule', {
value: true
});
var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var ExtendableError = (function (_Error) {
_inherits(ExtendableError, _Error);
function ExtendableError(message) {
_classCallCheck(this, ExtendableError);
Error.captureStackTrace(this, this.constructor);
this.message = message;
_get(Object.getPrototypeOf(ExtendableError.prototype), "constructor", this).call(this, message);
}
_get(Object.getPrototypeOf(ExtendableError.prototype), 'constructor', this).call(this, message);
_inherits(ExtendableError, _Error);
Object.defineProperty(this, 'name', {
enumerable: false,
value: this.constructor.name
});
_createClass(ExtendableError, {
name: {
get: function () {
return this.constructor.name;
}
if (Error.hasOwnProperty('captureStackTrace')) {
Error.captureStackTrace(this, this.constructor);
} else {
Object.defineProperty(this, 'stack', {
enumerable: false,
value: new Error(message).stack
});
}
});
}

@@ -33,2 +39,3 @@ return ExtendableError;

module.exports = ExtendableError;
exports['default'] = ExtendableError;
module.exports = exports['default'];
{
"name": "es6-error",
"version": "1.0.0",
"version": "2.0.0",
"description": "Easily-extendable error for use with ES6 classes",
"main": "dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha --compilers js:babel/register"
},

@@ -25,4 +25,7 @@ "repository": {

"devDependencies": {
"babel": "^4.7.16"
}
"babel": "^5.1.11",
"chai": "^3.2.0",
"mocha": "^2.3.2"
},
"dependencies": {}
}

@@ -6,2 +6,11 @@ # es6-error

Tested in Node 4.0, Chrome, and Firefox.
## Why?
I made this because I wanted to be able to extend Error for inheritance and type
checking, but can never remember to add
`Error.captureStackTrace(this, this.constructor.name)` to the constructor or how
to get the proper name to print from `console.log`.
## ES6 Usage

@@ -40,1 +49,6 @@

```
#### Todo
- Better browser compatibility
- Browser tests
class ExtendableError extends Error {
constructor(message) {
Error.captureStackTrace(this, this.constructor);
this.message = message;
super(message);
}
get name() {
return this.constructor.name;
Object.defineProperty(this, 'name', {
enumerable : false,
value : this.constructor.name,
});
if (Error.hasOwnProperty('captureStackTrace')) {
Error.captureStackTrace(this, this.constructor);
} else {
Object.defineProperty(this, 'stack', {
enumerable : false,
value : (new Error(message)).stack,
});
}
}

@@ -11,0 +19,0 @@ }

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