Comparing version 2.3.2 to 2.3.3
# Changelog | ||
<a name="2.3.3"></a> | ||
## 2.3.3 (2021-12-26) | ||
* fix: handle sync errors in `wrap()` | ||
<a name="2.3.2"></a> | ||
@@ -4,0 +9,0 @@ ## 2.3.2 (2020-12-08) |
@@ -279,3 +279,8 @@ 'use strict'; | ||
const numParameters = fn.length; | ||
const ret = fn.apply(context, args.slice(0, end).concat(_cb)); | ||
let ret; | ||
try { | ||
ret = fn.apply(context, args.slice(0, end).concat(_cb)); | ||
} catch (err) { | ||
return _cb(err); | ||
} | ||
@@ -282,0 +287,0 @@ if (checkForPromise) { |
{ | ||
"name": "kareem", | ||
"version": "2.3.2", | ||
"version": "2.3.3", | ||
"description": "Next-generation take on pre/post function hooks", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -322,2 +322,26 @@ var assert = require('assert'); | ||
it('catches sync errors', function(done) { | ||
hooks.pre('cook', function(done) { | ||
done(); | ||
}); | ||
hooks.post('cook', function(callback) { | ||
callback(); | ||
}); | ||
var args = []; | ||
args.push(function(error) { | ||
assert.equal(error.message, 'oops!'); | ||
done(); | ||
}); | ||
hooks.wrap( | ||
'cook', | ||
function() { | ||
throw new Error('oops!'); | ||
}, | ||
null, | ||
args); | ||
}); | ||
it('sync wrappers', function() { | ||
@@ -324,0 +348,0 @@ var calledPre = 0; |
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
101500
1654