New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

error-ninja

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

error-ninja - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

14

examples/example.js

@@ -16,6 +16,14 @@ 'use strict';

const CustomUriError = createErrorClass(`CustomUriError`);
const VideoStreamError = createErrorClass(`VideoStreamError`);
const FatalError = createErrorClass(`FatalError`);
// Create one error constructor at a time.
// const CustomUriError = createErrorClass(`CustomUriError`);
// const VideoStreamError = createErrorClass(`VideoStreamError`);
// const FatalError = createErrorClass(`FatalError`);
// Or create all error constructors at once.
const { CustomUriError, VideoStreamError, FatalError } = createErrorClass([
`CustomUriError`,
`VideoStreamError`,
`FatalError`,
]);
/**

@@ -22,0 +30,0 @@ * Faux function to demonstrate how native errors (e.g. an undefined variable) and error ninjas (new CustomUriError) get

@@ -10,3 +10,3 @@ {

"name": "error-ninja",
"version": "1.0.4",
"version": "1.0.5",
"description": "Allows us to pre-define error types and error messages in each module.",

@@ -13,0 +13,0 @@ "keywords": [

@@ -31,9 +31,26 @@ 'use strict';

/**
* Creates and returns a new error class.
* Creates and returns a new error class. Can optionally accept an array of class names to create multiple at a time.
*
* @param {String} errorName - The class name for the new error.
* @returns {ErrorClass} - The newly created error class.
* @param {String|Array<String>} input - The class name for the new error, or an array of class names.
* @returns {ErrorClass|dictionary<ErrorClass>} - The newly created error class, or a dictionary of error classes.
*/
function createErrorClass (errorName) {
function createErrorClass (input) {
let errorName;
// Cope with creating multiple error classes at once.
if (Array.isArray(input)) {
const output = input.reduce((acc, item) => {
acc[item] = createErrorClass(item);
return acc;
}, {});
return output;
}
// Or just create a single error class.
else {
errorName = input;
}
/**

@@ -40,0 +57,0 @@ * Create a new class of error.

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