Socket
Socket
Sign inDemoInstall

switchback

Package Overview
Dependencies
Maintainers
6
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

switchback - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

54

lib/index.js

@@ -112,10 +112,54 @@ /**

// Supply a handful of default handlers to provide better error messages.
var getWildcardCaseHandler = function(caseName, err) {
var getWildcardCaseHandler = function(caseName, switchbackErrorMsg) {
return function unknownCase( /* ... */ ) {
var args = Array.prototype.slice.call(arguments);
err = (args[0] ? util.inspect(args[0]) + ' ' : '') + (err ? '(' + (err || '') + ')' : '');
if (_.isObject(defaultHandlers) && _.isFunction(defaultHandlers['*'])) {
return defaultHandlers['*'](err);
} else throw new Error(err);
// Build an error message that combines the error msg from switchback
// with the actual error being passed in to the callback.
var combinedError = '';
// Build up a pretty-printed version of the actual error from the callback
// (maintain the stack trace if at all possible)
var actualErr = args[0];
if (!_.isUndefined(actualErr)) {
var prettifiedActualErr;
if (_.isObject(actualErr) && actualErr instanceof Error){
prettifiedActualErr = actualErr.stack;
}
else {
prettifiedActualErr = util.inspect(args[0], false, null);
}
combinedError += prettifiedActualErr;
}
// Add on the error msg from switchback
if (!_.isUndefined(switchbackErrorMsg)) {
combinedError += ' ' + switchbackErrorMsg;
}
// If a callback fn exists under the '*' or 'error' key in default handlers, call it
if (_.isObject(defaultHandlers)){
if (_.isFunction(defaultHandlers['*'])) {
return defaultHandlers['*'](combinedError);
}
if (_.isFunction(defaultHandlers.error)) {
return defaultHandlers.error(combinedError);
}
}
// If a callback fn exists under the '*' or 'error' key in Switchback, call it
if (_.isObject(Switchback)){
if (_.isFunction(Switchback['*'])) {
return Switchback['*'](combinedError);
}
if (_.isFunction(Switchback.error)) {
return Switchback.error(combinedError);
}
}
// console.log('defaultHandlers', defaultHandlers);
// console.log('Switchback', Switchback);
// console.log('Switchback["*"]', Switchback['*']);
// console.log('Switchback["error"]', Switchback['error']);
// Otherwise just throw out of frustration
throw new Error(combinedError);
};

@@ -122,0 +166,0 @@ };

2

package.json
{
"name": "switchback",
"version": "1.1.2",
"version": "1.1.3",
"description": "Normalize callback fns to switchbacks and vice versa",

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

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