index.js.flow 846 B

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