Skip to content

Commit

Permalink
fix(wrap): ensure fast path still wraps function in nextTick() for …
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Mar 22, 2018
1 parent 3286612 commit 7000494
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions index.js
Expand Up @@ -305,8 +305,11 @@ Kareem.prototype.wrap = function(name, fn, context, args, options) {
Kareem.prototype.createWrapper = function(name, fn, context, options) {
var _this = this;
if (this._pres[name] == null && this._posts[name] == null) {
// Fast path: if there's no hooks for this function, just return the function
return fn;
// Fast path: if there's no hooks for this function, just return the
// function wrapped in a nextTick()
return function() {
process.nextTick(() => fn.apply(this, arguments));
};
}
return function() {
var _context = context || this;
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7000494

Please sign in to comment.