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

dry-underscore

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dry-underscore - npm Package Compare versions

Comparing version 0.17.3 to 0.17.4

9

lib/common.js

@@ -355,10 +355,3 @@ "use strict";

_.exception = function(code, message, extra){
if(message === undefined && extra === undefined){ return(_.type(code, 'exception')); }
extra = extra || {};
if(extra.message){ extra.originalMessage = extra.message; }
if(extra.code){ extra.originalCode = extra.code; }
return(_.extend({
type: 'exception',
stack: (new Error(message)).stack
}, extra, { code: code, message: message }));
return(_.error(code, message, _.extend({}, extra, { type: 'exception' })));
};

@@ -365,0 +358,0 @@

44

lib/common.test.js

@@ -24,3 +24,3 @@ "use strict";

var caught = false;
try{ f(); }catch(e){ caught = true; }
try{ f(); }catch(e){ _.p(e); caught = true; }
if(caught){ throw(_.error("unexpected_throw", "eq didn't work.")); }

@@ -41,2 +41,22 @@ }

// test throws
no_throws(function(){
_.test.throws(function(){ throw(_.error("code")); });
});
no_throws(function(){
_.test.throws(function(){ throw(_.error("code")); }, "code");
});
no_throws(function(){
_.test.throws(function(){ throw(_.error("code")); }, function(){ return(true); });
});
throws(function(){
_.test.throws(function(){ throw(_.error("code")); }, "other_code");
});
throws(function(){
_.test.throws(function(){ throw(_.error("code")); }, function(){ return(false) });
});
});

@@ -503,11 +523,29 @@

test("exception", function(){
var just_code = _.exception("just_code");
eq(just_code.type, "exception");
eq(just_code.code, "just_code");
eq(just_code.message, undefined);
var e = _.exception("a_code", "a_message");
eq(e.type, "exception");
eq(e.code, "a_code");
eq(e.message, "a_message");
});
test("error", function(){
var e = _.error("a_code", "a_message");
var just_code = _.error("just_code");
eq(just_code.type, "error");
eq(just_code.code, "just_code");
eq(just_code.message, undefined);
var e = _.error("a_code", "a_message");
eq(e.type, "error");
eq(e.code, "a_code");

@@ -514,0 +552,0 @@ eq(e.message, "a_message");

@@ -26,10 +26,24 @@

test.throws = function(f){
test.throws = function(f, filter, filter_message){
var threw = false;
filter = filter || function(){ return(true); };
try{ f(); }
catch(e){ threw = true; }
catch(e){
threw = true;
if(_.isString(filter)){
var filter_string = filter;
filter = function(err){ return(_.code(err, filter_string)); }
filter_message = filter_message || "Function threw an error, but the code was unexpected. actual code: " + _.code(e) + " expected code: " + filter_string;
}
if(!filter(e)){
throw(_.exception("wrong_code", filter_message || "Function threw an error, but the code was unexpected. actual code: " + _.code(e)));
}
}
if(!threw){
throw(_.exception("NoThrow", "Expected function to throw an error, it didn't."));
throw(_.exception("no_throw", "Expected function to throw an error, it didn't."));
}

@@ -36,0 +50,0 @@ };

{
"name": "dry-underscore",
"version": "0.17.3",
"version": "0.17.4",
"dependencies": {

@@ -5,0 +5,0 @@ "deep-diff": {

{
"name": "dry-underscore",
"version": "0.17.3",
"version": "0.17.4",
"main": "./lib/index.js",

@@ -5,0 +5,0 @@ "description": "The DRY Undescore Library",

Sorry, the diff of this file is too big to display

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