Skip to content

Commit

Permalink
chore: bump marked re: security
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Jan 9, 2018
1 parent 25a32ee commit cc564a9
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 25 deletions.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,33 @@ async pre hooks have called `done()`.

```

#### 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

#### It runs without any hooks specified
Expand Down Expand Up @@ -377,3 +404,25 @@ async pre hooks have called `done()`.

```

## 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);

```

51 changes: 27 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"url": "git://github.com/vkarpov15/kareem.git"
},
"devDependencies": {
"acquit": "0.4.1",
"acquit": "0.5.1",
"gulp": "3.8.10",
"gulp-mocha": "2.0.0",
"gulp-jscs": "1.4.0",
Expand Down

0 comments on commit cc564a9

Please sign in to comment.