UNPKG

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