1 | export as namespace regeneratorRuntime;
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | export type InnerFunction<T = undefined, TYield = unknown, TReturn = unknown, TNext = unknown> = (
|
7 | this: T,
|
8 | context: Context<TYield, TReturn, TNext>,
|
9 | ) => unknown;
|
10 |
|
11 | export type ContextLocation = number | "end";
|
12 | export type CompletionType = "normal" | "return" | "throw" | "break" | "continue";
|
13 |
|
14 |
|
15 | export type TryLocationsList = ReadonlyArray<
|
16 | | readonly [number, number]
|
17 | | readonly [number, number | undefined, number, ContextLocation]
|
18 | >;
|
19 |
|
20 | export interface CompletionRecord {
|
21 | type: CompletionType;
|
22 | arg: unknown;
|
23 | }
|
24 |
|
25 | export interface TryEntry {
|
26 | readonly tryLoc: number;
|
27 | readonly catchLoc?: number | undefined;
|
28 | readonly finallyLoc?: number | undefined;
|
29 | readonly afterLoc?: ContextLocation | undefined;
|
30 | completion?: CompletionRecord | undefined;
|
31 | }
|
32 |
|
33 | export interface DelegatedIterator {
|
34 | iterator: Iterator<unknown, unknown, unknown>;
|
35 | }
|
36 |
|
37 | export interface Context<TYield = unknown, TReturn = unknown, TNext = unknown> {
|
38 | readonly tryEntries: readonly [
|
39 | { readonly tryLoc: "root" } & Omit<TryEntry, "tryLoc">,
|
40 | ...TryEntry[],
|
41 | ];
|
42 |
|
43 | |
44 |
|
45 |
|
46 | sent: TNext;
|
47 |
|
48 | |
49 |
|
50 |
|
51 | prev: unknown;
|
52 |
|
53 | |
54 |
|
55 |
|
56 | next: number | "end";
|
57 |
|
58 | |
59 |
|
60 |
|
61 | done: boolean;
|
62 |
|
63 | |
64 |
|
65 |
|
66 | rval: TReturn;
|
67 |
|
68 | |
69 |
|
70 |
|
71 | delegate: DelegatedIterator | undefined;
|
72 |
|
73 | |
74 |
|
75 |
|
76 | method: "next" | "return" | "throw";
|
77 |
|
78 | |
79 |
|
80 |
|
81 | arg: unknown;
|
82 |
|
83 | reset(skipTempReset?: boolean): void;
|
84 |
|
85 | |
86 |
|
87 |
|
88 | stop(): TReturn;
|
89 |
|
90 | |
91 |
|
92 |
|
93 |
|
94 |
|
95 | dispatchException(exception: unknown): boolean;
|
96 |
|
97 | |
98 |
|
99 |
|
100 |
|
101 | abrupt(type: "return", rval?: TReturn): unknown;
|
102 |
|
103 | |
104 |
|
105 |
|
106 |
|
107 | abrupt(type: "throw", exception?: unknown): never;
|
108 |
|
109 | |
110 |
|
111 |
|
112 |
|
113 | abrupt(type: "break" | "continue", nextLoc: number): unknown;
|
114 |
|
115 | |
116 |
|
117 |
|
118 |
|
119 | abrupt(type: CompletionType, arg?: unknown): unknown;
|
120 |
|
121 | |
122 |
|
123 |
|
124 |
|
125 | complete(record: Readonly<CompletionRecord>, afterLoc?: ContextLocation): unknown;
|
126 |
|
127 | |
128 |
|
129 |
|
130 |
|
131 |
|
132 | finish(finallyLoc: number): unknown;
|
133 |
|
134 | |
135 |
|
136 |
|
137 |
|
138 |
|
139 | catch(tryLoc: number): unknown;
|
140 |
|
141 | |
142 |
|
143 |
|
144 |
|
145 |
|
146 | delegateYield(
|
147 | iterable: { [Symbol.iterator](): Iterator<TYield, unknown, unknown> },
|
148 | resultName: string,
|
149 | nextLoc: ContextLocation,
|
150 | ): unknown;
|
151 |
|
152 | [
|
153 | |
154 |
|
155 |
|
156 | temp: string
|
157 | ]: any;
|
158 | }
|
159 |
|
160 | export function wrap<T = undefined, TYield = unknown, TReturn = unknown, TNext = unknown>(
|
161 | innerFn: InnerFunction<T, TYield, TReturn, TNext>,
|
162 |
|
163 | outerFn?: Function | null,
|
164 | self?: T,
|
165 | tryLocsList?: TryLocationsList,
|
166 | ): Generator<TYield, TReturn, TNext>;
|
167 |
|
168 | export interface ResolvablePromiseConstructorLike extends PromiseConstructorLike {
|
169 | resolve<T = void>(value?: T): PromiseLike<T>;
|
170 | }
|
171 |
|
172 | export class AsyncIterator<TYield = unknown, TReturn = unknown, TNext = unknown>
|
173 | implements globalThis.AsyncIterator<TYield, TReturn, TNext>
|
174 | {
|
175 | constructor(
|
176 | generator: Generator<
|
177 | TYield | PromiseLike<TYield> | awrap<unknown>,
|
178 | TReturn | PromiseLike<TReturn> | awrap<unknown>
|
179 | >,
|
180 | PromiseImpl: ResolvablePromiseConstructorLike,
|
181 | );
|
182 |
|
183 | // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
|
184 | next(...args: [] | [TNext]): Promise<IteratorResult<TYield, TReturn>>;
|
185 | return(value: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<TYield, TReturn>>;
|
186 | throw(e: any): Promise<IteratorResult<TYield, TReturn>>;
|
187 |
|
188 | [Symbol.asyncIterator](): this;
|
189 | }
|
190 |
|
191 | export function async<T = undefined, TYield = unknown, TReturn = unknown>(
|
192 | innerFn: InnerFunction<T, TYield, TReturn>,
|
193 | outerFn: GeneratorFunction,
|
194 | self?: T,
|
195 | tryLocsList?: TryLocationsList,
|
196 | PromiseImpl?: ResolvablePromiseConstructorLike,
|
197 | ): AsyncIterator<
|
198 | TYield extends PromiseLike<infer Await> ? Await : Exclude<TYield, awrap<unknown>>,
|
199 | TReturn extends PromiseLike<infer Await> ? Await : Exclude<TReturn, awrap<unknown>>
|
200 | >;
|
201 | export function async<T = undefined, TReturn = unknown>(
|
202 | innerFn: InnerFunction<T, unknown, TReturn>,
|
203 |
|
204 | outerFn?: Function | null,
|
205 | self?: T,
|
206 | tryLocsList?: TryLocationsList,
|
207 | PromiseImpl?: ResolvablePromiseConstructorLike,
|
208 | ): Promise<TReturn extends PromiseLike<infer Await> ? Await : TReturn>;
|
209 |
|
210 | export function awrap<V>(arg: V): awrap<V>;
|
211 | export class awrap<V> {
|
212 | constructor(arg: V);
|
213 |
|
214 | // Used to tell TypeScript that this class is to be treated as a nominal type:
|
215 | private readonly "#private";
|
216 |
|
217 | readonly __await: V;
|
218 | }
|
219 |
|
220 | export function isGeneratorFunction(func: unknown): func is GeneratorFunction;
|
221 |
|
222 | export function keys(object: {}): () => IteratorResult<string, undefined>;
|
223 |
|
224 | // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
225 | export function mark<F extends Function>(genFun: F): F & GeneratorFunction;
|
226 |
|
227 | export function values<I extends Iterator<unknown, unknown, unknown>>(iterable: { [Symbol.iterator](): I }): I;
|
228 | export function values<T>(iterableOrArrayLike: Iterable<T> | ArrayLike<T>): Iterator<T, unknown, unknown>;
|