Comparing version 2.0.0-rc1 to 2.0.0-rc2
23
index.js
@@ -35,3 +35,3 @@ 'use strict'; | ||
var args = [ | ||
once(function(error) { | ||
decorateNextFn(function(error) { | ||
if (error) { | ||
@@ -51,3 +51,3 @@ if (done) { | ||
}), | ||
once(function(error) { | ||
decorateNextFn(function(error) { | ||
if (error) { | ||
@@ -73,3 +73,3 @@ if (done) { | ||
var args = [ | ||
once(function(error) { | ||
decorateNextFn(function(error) { | ||
if (error) { | ||
@@ -171,3 +171,3 @@ if (done) { | ||
if (post.length === numArgs + 2) { | ||
var _cb = once(function(error) { | ||
var _cb = decorateNextFn(function(error) { | ||
if (error) { | ||
@@ -201,3 +201,3 @@ firstError = error; | ||
if (post.length === numArgs + 1) { | ||
var _cb = once(function(error) { | ||
var _cb = decorateNextFn(function(error) { | ||
if (error) { | ||
@@ -297,3 +297,5 @@ firstError = error; | ||
var end = (typeof lastArg === 'function' ? args.length - 1 : args.length); | ||
fn.apply(context, args.slice(0, end).concat(function() { | ||
fn.apply(context, args.slice(0, end).concat(_cb)); | ||
function _cb() { | ||
var args = arguments; | ||
@@ -321,3 +323,3 @@ var argsWithoutError = Array.prototype.slice.call(arguments, 1); | ||
} | ||
})); | ||
} | ||
}); | ||
@@ -404,6 +406,7 @@ }; | ||
function once(fn) { | ||
function decorateNextFn(fn) { | ||
var called = false; | ||
var _this = this; | ||
return function() { | ||
// Ensure this function can only be called once | ||
if (called) { | ||
@@ -413,3 +416,5 @@ return; | ||
called = true; | ||
return fn.apply(_this, arguments); | ||
// Make sure to clear the stack so try/catch doesn't catch errors | ||
// in subsequent middleware | ||
return setImmediate(() => fn.apply(_this, arguments)); | ||
}; | ||
@@ -416,0 +421,0 @@ } |
{ | ||
"name": "kareem", | ||
"version": "2.0.0-rc1", | ||
"version": "2.0.0-rc2", | ||
"description": "Next-generation take on pre/post function hooks", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
58561
1377