koa-convert
Advanced tools
+6
-2
@@ -16,5 +16,7 @@ 'use strict' | ||
| } | ||
| return function (ctx, next) { | ||
| const converted = function (ctx, next) { | ||
| return co.call(ctx, mw.call(ctx, createGenerator(next))) | ||
| } | ||
| converted._name = mw._name || mw.name | ||
| return converted | ||
| } | ||
@@ -43,3 +45,3 @@ | ||
| } | ||
| return function * (next) { | ||
| const converted = function * (next) { | ||
| let ctx = this | ||
@@ -58,2 +60,4 @@ let called = false | ||
| } | ||
| converted._name = mw._name || mw.name | ||
| return converted | ||
| } |
+1
-1
| { | ||
| "name": "koa-convert", | ||
| "version": "1.1.0", | ||
| "version": "1.2.0", | ||
| "keywords": [ | ||
@@ -5,0 +5,0 @@ "koa", |
+10
-0
@@ -28,2 +28,7 @@ /* global describe, it */ | ||
| it('should inherit the original middleware name', () => { | ||
| let mw = convert(function * testing (next) {}) | ||
| assert.strictEqual(mw._name, 'testing') | ||
| }) | ||
| it('should work with `yield next`', () => { | ||
@@ -200,2 +205,7 @@ let call = [] | ||
| }) | ||
| it('should inherit the original middleware name', () => { | ||
| let mw = convert.back(function testing (ctx, next) {}) | ||
| assert.strictEqual(mw._name, 'testing') | ||
| }) | ||
| }) | ||
@@ -202,0 +212,0 @@ |
12295
3.97%277
4.53%