Skip to content

Commit

Permalink
feat: add hasHooks()
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Apr 28, 2018
1 parent f3d406b commit 225f18d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Expand Up @@ -302,9 +302,13 @@ Kareem.prototype.wrap = function(name, fn, context, args, options) {
});
};

Kareem.prototype.hasHooks = function(name) {
return this._pres[name] != null || this._posts[name] != null;
};

Kareem.prototype.createWrapper = function(name, fn, context, options) {
var _this = this;
if (this._pres[name] == null && this._posts[name] == null) {
if (!this.hasHooks(name)) {
// Fast path: if there's no hooks for this function, just return the
// function wrapped in a nextTick()
return function() {
Expand Down

0 comments on commit 225f18d

Please sign in to comment.