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

error-class

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

error-class - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

23

index.js

@@ -5,6 +5,3 @@ // Memoize these results, they're basically invariants.

// Invalid JavaScript identifiers.
var invalidName = /[^0-9a-zA-Z_$]/
module.exports = function errorClass (name, fn) {

@@ -14,8 +11,5 @@ if (!name || typeof name !== 'string')

if (invalidName.test(name))
throw Error('Argument "name" is an invalid identifier.')
// This is basically `eval`, there's no other way to dynamically define a
// function name.
var error = Function('setupError', 'fn',
var ErrorClass = Function('setupError', 'fn',
'return function ' + name + ' () { ' +

@@ -29,11 +23,12 @@ 'if (!(this instanceof ' + name + ')) ' +

error.prototype = Object.create(Error.prototype, {
constructor: nonEnumerableProperty(error),
ErrorClass.prototype = Object.create(Error.prototype, {
constructor: nonEnumerableProperty(ErrorClass),
name: nonEnumerableProperty(name)
})
if (hasSetPrototypeOf) Object.setPrototypeOf(error, Error)
else error.__proto__ = Error
// The `setPrototypeOf` method is part of ES6.
if (hasSetPrototypeOf) Object.setPrototypeOf(ErrorClass, Error)
else ErrorClass.__proto__ = Error
return error
return ErrorClass
}

@@ -52,2 +47,4 @@

// Use the `+` operator with an empty string to implicitly type cast the
// `message` argument into a string.
Object.defineProperty(this, 'message',

@@ -59,5 +56,5 @@ nonEnumerableProperty(message !== undefined ? '' + message : ''))

function nonEnumerableProperty (value) {
// The field `enumerable` is `false` by default.
return {
value: value,
enumerable: false,
writable: true,

@@ -64,0 +61,0 @@ configurable: true

{
"name": "error-class",
"description": "Typed errors that closely emulate the native Error class.",
"version": "1.1.0",
"version": "1.1.1",
"license": "MIT",

@@ -6,0 +6,0 @@ "author": {

@@ -19,2 +19,4 @@ # Error Class

```js
import errorClass from 'error-class'
const SpecialError = errorClass('SpecialError', function () {

@@ -21,0 +23,0 @@ if (arguments.length > 1) this.specialProperty = arguments[1]

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