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