Comparing version 2.0.0-rc5 to 2.0.0
{ | ||
"name": "kareem", | ||
"version": "2.0.0-rc5", | ||
"version": "2.0.0", | ||
"description": "Next-generation take on pre/post function hooks", | ||
@@ -15,3 +15,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"acquit": "0.4.1", | ||
"acquit": "0.5.1", | ||
"gulp": "3.8.10", | ||
@@ -18,0 +18,0 @@ "gulp-mocha": "2.0.0", |
@@ -181,2 +181,29 @@ # kareem | ||
#### It supports returning a promise | ||
You can also return a promise from your pre hooks instead of calling | ||
`next()`. When the returned promise resolves, kareem will kick off the | ||
next middleware. | ||
```javascript | ||
hooks.pre('cook', function() { | ||
return new Promise(resolve => { | ||
setTimeout(() => { | ||
this.bacon = 3; | ||
resolve(); | ||
}, 100); | ||
}); | ||
}); | ||
var obj = { bacon: 0 }; | ||
hooks.execPre('cook', obj, function() { | ||
assert.equal(3, obj.bacon); | ||
done(); | ||
}); | ||
``` | ||
## post hooks | ||
@@ -381,1 +408,23 @@ | ||
## merge() | ||
#### It pulls hooks from another Kareem object | ||
```javascript | ||
var k1 = new Kareem(); | ||
var test1 = function() {}; | ||
k1.pre('cook', test1); | ||
k1.post('cook', function() {}); | ||
var k2 = new Kareem(); | ||
var test2 = function() {}; | ||
k2.pre('cook', test2); | ||
var k3 = k2.merge(k1); | ||
assert.equal(k3._pres['cook'].length, 2); | ||
assert.equal(k3._pres['cook'][0].fn, test2); | ||
assert.equal(k3._pres['cook'][1].fn, test1); | ||
assert.equal(k3._posts['cook'].length, 1); | ||
``` | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
60392
1
429
12