lib.es2018.asyncgenerator.d.ts 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*! *****************************************************************************
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  4. this file except in compliance with the License. You may obtain a copy of the
  5. License at http://www.apache.org/licenses/LICENSE-2.0
  6. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  7. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  8. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  9. MERCHANTABLITY OR NON-INFRINGEMENT.
  10. See the Apache Version 2.0 License for specific language governing permissions
  11. and limitations under the License.
  12. ***************************************************************************** */
  13. /// <reference no-default-lib="true"/>
  14. /// <reference lib="es2018.asynciterable" />
  15. interface AsyncGenerator<T = unknown, TReturn = any, TNext = unknown> extends AsyncIterator<T, TReturn, TNext> {
  16. // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
  17. next(...args: [] | [TNext]): Promise<IteratorResult<T, TReturn>>;
  18. return(value: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<T, TReturn>>;
  19. throw(e: any): Promise<IteratorResult<T, TReturn>>;
  20. [Symbol.asyncIterator](): AsyncGenerator<T, TReturn, TNext>;
  21. }
  22. interface AsyncGeneratorFunction {
  23. /**
  24. * Creates a new AsyncGenerator object.
  25. * @param args A list of arguments the function accepts.
  26. */
  27. new (...args: any[]): AsyncGenerator;
  28. /**
  29. * Creates a new AsyncGenerator object.
  30. * @param args A list of arguments the function accepts.
  31. */
  32. (...args: any[]): AsyncGenerator;
  33. /**
  34. * The length of the arguments.
  35. */
  36. readonly length: number;
  37. /**
  38. * Returns the name of the function.
  39. */
  40. readonly name: string;
  41. /**
  42. * A reference to the prototype.
  43. */
  44. readonly prototype: AsyncGenerator;
  45. }
  46. interface AsyncGeneratorFunctionConstructor {
  47. /**
  48. * Creates a new AsyncGenerator function.
  49. * @param args A list of arguments the function accepts.
  50. */
  51. new (...args: string[]): AsyncGeneratorFunction;
  52. /**
  53. * Creates a new AsyncGenerator function.
  54. * @param args A list of arguments the function accepts.
  55. */
  56. (...args: string[]): AsyncGeneratorFunction;
  57. /**
  58. * The length of the arguments.
  59. */
  60. readonly length: number;
  61. /**
  62. * Returns the name of the function.
  63. */
  64. readonly name: string;
  65. /**
  66. * A reference to the prototype.
  67. */
  68. readonly prototype: AsyncGeneratorFunction;
  69. }