kareem 2.0.1 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +5 -1
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -304,6 +304,10 @@ Kareem.prototype.wrap = function(name, fn, context, args, options) {
304
304
 
305
305
  Kareem.prototype.createWrapper = function(name, fn, context, options) {
306
306
  var _this = this;
307
+ if (this._pres[name] == null && this._posts[name] == null) {
308
+ // Fast path: if there's no hooks for this function, just return the function
309
+ return fn;
310
+ }
307
311
  return function() {
308
312
  var _context = context || this;
309
313
  var args = Array.prototype.slice.call(arguments);
@@ -417,7 +421,7 @@ function decorateNextFn(fn) {
417
421
  called = true;
418
422
  // Make sure to clear the stack so try/catch doesn't catch errors
419
423
  // in subsequent middleware
420
- return setImmediate(() => fn.apply(_this, arguments));
424
+ return process.nextTick(() => fn.apply(_this, arguments));
421
425
  };
422
426
  }
423
427
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kareem",
3
- "version": "2.0.1",
3
+ "version": "2.0.5",
4
4
  "description": "Next-generation take on pre/post function hooks",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -26,5 +26,5 @@
26
26
  "disallowMultipleVarDecl": true
27
27
  },
28
28
  "author": "Valeri Karpov <val@karpov.io>",
29
- "license": "Apache 2.0"
29
+ "license": "Apache-2.0"
30
30
  }