Comparing version 0.4.0 to 0.4.1
{ | ||
"name": "lazy-ass", | ||
"main": "index.js", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"homepage": "https://github.com/bahmutov/lazy-ass", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -12,3 +12,10 @@ (function initLazyAss() { | ||
if (typeof arg === 'function') { | ||
return total + arg(); | ||
var fnResult; | ||
try { | ||
fnResult = arg(); | ||
} catch (err) { | ||
// ignore the error | ||
fnResult = '[function ' + arg.name + ' threw error!]'; | ||
} | ||
return total + fnResult; | ||
} | ||
@@ -15,0 +22,0 @@ if (Array.isArray(arg)) { |
{ | ||
"name": "lazy-ass", | ||
"description": "Lazy assertions without performance penalty", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>", | ||
@@ -6,0 +6,0 @@ "bugs": { |
@@ -68,2 +68,16 @@ /* global lazyAss */ | ||
it('handles exception if thrown from function', function () { | ||
var called = 0; | ||
function foo() { | ||
called += 1; | ||
throw new Error('Oh no!'); | ||
} | ||
expect(function () { | ||
lazyAss(false, foo, 'bar', foo); | ||
}).to.throwException(function (err) { | ||
expect(called).to.equal(2); | ||
expect(err.message).to.contain('bar'); | ||
}); | ||
}); | ||
it('JSON stringifies arrays', function () { | ||
@@ -70,0 +84,0 @@ expect(function () { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22455
387