[6a3a178] | 1 | // @flow
|
---|
| 2 |
|
---|
| 3 | opaque type Next = Function | void;
|
---|
| 4 | opaque type Yield = mixed;
|
---|
| 5 |
|
---|
| 6 | export type Gensync<Args, Return> = {
|
---|
| 7 | (...args: Args): Handler<Return>,
|
---|
| 8 | sync(...args: Args): Return,
|
---|
| 9 | async(...args: Args): Promise<Return>,
|
---|
| 10 | // ...args: [...Args, Callback]
|
---|
| 11 | errback(...args: any[]): void,
|
---|
| 12 | };
|
---|
| 13 |
|
---|
| 14 | export type Handler<Return> = Generator<Yield, Return, Next>;
|
---|
| 15 | export type Options<Args, Return> = {
|
---|
| 16 | sync(...args: Args): Return,
|
---|
| 17 | arity?: number,
|
---|
| 18 | name?: string,
|
---|
| 19 | } & (
|
---|
| 20 | | { async?: (...args: Args) => Promise<Return> }
|
---|
| 21 | // ...args: [...Args, Callback]
|
---|
| 22 | | { errback(...args: any[]): void }
|
---|
| 23 | );
|
---|
| 24 |
|
---|
| 25 | declare module.exports: {
|
---|
| 26 | <Args, Return>(
|
---|
| 27 | Options<Args, Return> | ((...args: Args) => Handler<Return>)
|
---|
| 28 | ): Gensync<Args, Return>,
|
---|
| 29 |
|
---|
| 30 | all<Return>(Array<Handler<Return>>): Handler<Return[]>,
|
---|
| 31 | race<Return>(Array<Handler<Return>>): Handler<Return>,
|
---|
| 32 | };
|
---|