mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-24 11:29:30 +08:00
Merge pull request #8077 from jkeylu/koa-compose
add definitions for koa-compose
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
/// <reference path="koa-compose-2.3.1.d.ts" />
|
||||
|
||||
import compose = require('koa-compose');
|
||||
|
||||
var fn1: compose.Middleware = function *(next: void) {
|
||||
console.log('in fn1');
|
||||
yield next;
|
||||
}
|
||||
|
||||
var fn2: compose.Middleware = function *(next: void) {
|
||||
console.log('in fn2');
|
||||
yield next;
|
||||
}
|
||||
|
||||
var fn = compose([fn1, fn2]);
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// Type definitions for koa v2.3.1
|
||||
// Project: https://github.com/koajs/compose
|
||||
// Definitions by: jKey Lu <https://github.com/jkeylu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "koa-compose" {
|
||||
function compose(middleware: compose.Middleware[]): compose.ComposedMiddleware;
|
||||
|
||||
module compose {
|
||||
interface Middleware {
|
||||
(next?: void): IterableIterator<any>;
|
||||
}
|
||||
|
||||
interface ComposedMiddleware {
|
||||
(): IterableIterator<any>;
|
||||
}
|
||||
}
|
||||
|
||||
export = compose;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/// <reference path="koa-compose.d.ts" />
|
||||
|
||||
import compose = require('koa-compose');
|
||||
|
||||
var fn1: compose.Middleware = function(context: any, next: () => Promise<void>): Promise<any> {
|
||||
return Promise
|
||||
.resolve(console.log('in fn1'))
|
||||
.then(() => next());
|
||||
};
|
||||
|
||||
var fn2: compose.Middleware = function(context: any, next: () => Promise<void>): Promise<any> {
|
||||
return Promise
|
||||
.resolve(console.log('in fn2'))
|
||||
.then(() => next());
|
||||
};
|
||||
|
||||
|
||||
var fn = compose([fn1, fn2]);
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// Type definitions for koa v3.0.0
|
||||
// Project: https://github.com/koajs/compose
|
||||
// Definitions by: jKey Lu <https://github.com/jkeylu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "koa-compose" {
|
||||
function compose(middleware: compose.Middleware[]): compose.ComposedMiddleware;
|
||||
|
||||
module compose {
|
||||
interface Middleware {
|
||||
(context: any, next?: () => Promise<void>): Promise<any>;
|
||||
}
|
||||
|
||||
interface ComposedMiddleware {
|
||||
(context: any): Promise<void>;
|
||||
}
|
||||
}
|
||||
|
||||
export = compose;
|
||||
}
|
||||
Reference in New Issue
Block a user