You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
846 B
33 lines
846 B
4 years ago
|
// @flow
|
||
|
|
||
|
opaque type Next = Function | void;
|
||
|
opaque type Yield = mixed;
|
||
|
|
||
|
export type Gensync<Args, Return> = {
|
||
|
(...args: Args): Handler<Return>,
|
||
|
sync(...args: Args): Return,
|
||
|
async(...args: Args): Promise<Return>,
|
||
|
// ...args: [...Args, Callback]
|
||
|
errback(...args: any[]): void,
|
||
|
};
|
||
|
|
||
|
export type Handler<Return> = Generator<Yield, Return, Next>;
|
||
|
export type Options<Args, Return> = {
|
||
|
sync(...args: Args): Return,
|
||
|
arity?: number,
|
||
|
name?: string,
|
||
|
} & (
|
||
|
| { async?: (...args: Args) => Promise<Return> }
|
||
|
// ...args: [...Args, Callback]
|
||
|
| { errback(...args: any[]): void }
|
||
|
);
|
||
|
|
||
|
declare module.exports: {
|
||
|
<Args, Return>(
|
||
|
Options<Args, Return> | ((...args: Args) => Handler<Return>)
|
||
|
): Gensync<Args, Return>,
|
||
|
|
||
|
all<Return>(Array<Handler<Return>>): Handler<Return[]>,
|
||
|
race<Return>(Array<Handler<Return>>): Handler<Return>,
|
||
|
};
|