Skip to content

Commit

Permalink
Merge pull request koajs#3 from koajs/yield-delegate
Browse files Browse the repository at this point in the history
yield*
  • Loading branch information
jonathanong committed Nov 10, 2013
2 parents d022039 + 516b12c commit 767da19
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 2 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function compose(middleware){
if (!mw) {
if (done) throw new Error('middleware yielded control multiple times');
done = true;
return downstream || noop;
return downstream || noop();
}

return mw.call(ctx, next());
Expand All @@ -43,6 +43,4 @@ function compose(middleware){
* @api private
*/

function noop(done){
done();
}
function *noop(){}
10 changes: 10 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ describe('Koa Compose', function(){
co(compose(stack))(done);
})

it('should work when yielding at the end of the stack with yield*', function(done) {
var stack = [];

stack.push(function *(next){
yield* next;
});

co(compose(stack))(done);
})

it('should keep the context', function(done){
var ctx = {};

Expand Down

0 comments on commit 767da19

Please sign in to comment.