Skip to content

Commit

Permalink
perf(createWrapper): don't create wrapper if there are no hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Feb 22, 2018
1 parent 2ab0293 commit 5afc5b9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions index.js
Expand Up @@ -304,6 +304,10 @@ 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;
}
return function() {
var _context = context || this;
var args = Array.prototype.slice.call(arguments);
Expand Down

0 comments on commit 5afc5b9

Please sign in to comment.