kareem 2.2.0 → 2.2.1

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.
package/index.js CHANGED
@@ -400,7 +400,7 @@ Kareem.prototype.merge = function(other) {
400
400
  // Deduplicate based on `fn`
401
401
  filter(p => sourcePres.map(_p => _p.fn).indexOf(p.fn) === -1);
402
402
  const combined = sourcePres.concat(deduplicated);
403
- combined.numAsync = ret._pres.get(key).numAsync || 0;
403
+ combined.numAsync = sourcePres.numAsync || 0;
404
404
  combined.numAsync += deduplicated.filter(p => p.isAsync).length;
405
405
  ret._pres.set(key, combined);
406
406
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kareem",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Next-generation take on pre/post function hooks",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/test/misc.test.js CHANGED
@@ -9,3 +9,25 @@ describe('hasHooks', function() {
9
9
  assert.ok(!k.hasHooks('toString'));
10
10
  });
11
11
  });
12
+
13
+ describe('merge', function() {
14
+ it('handles async pres if source doesnt have them', function() {
15
+ const k1 = new Kareem();
16
+ k1.pre('cook', true, function(next, done) {
17
+ execed.first = true;
18
+ setTimeout(
19
+ function() {
20
+ done('error!');
21
+ },
22
+ 5);
23
+
24
+ next();
25
+ });
26
+
27
+ assert.equal(k1._pres.get('cook').numAsync, 1);
28
+
29
+ const k2 = new Kareem();
30
+ const k3 = k2.merge(k1);
31
+ assert.equal(k3._pres.get('cook').numAsync, 1);
32
+ });
33
+ });