@@ -190,7 +190,7 @@ type SomeChunk<T> =
190
190
| ErroredChunk<T>;
191
191
192
192
// $FlowFixMe[missing-this-annot]
193
- function Chunk (status: any, value: any, reason: any, response: Response) {
193
+ function ReactPromise (status: any, value: any, reason: any, response: Response) {
194
194
this.status = status;
195
195
this.value = value;
196
196
this.reason = reason;
@@ -200,9 +200,9 @@ function Chunk(status: any, value: any, reason: any, response: Response) {
200
200
}
201
201
}
202
202
// We subclass Promise.prototype so that we get other methods like .catch
203
- Chunk .prototype = (Object.create(Promise.prototype): any);
203
+ ReactPromise .prototype = (Object.create(Promise.prototype): any);
204
204
// TODO: This doesn't return a new Promise chain unlike the real .then
205
- Chunk .prototype.then = function <T>(
205
+ ReactPromise .prototype.then = function <T>(
206
206
this: SomeChunk<T>,
207
207
resolve: (value: T) => mixed,
208
208
reject?: (reason: mixed) => mixed,
@@ -303,20 +303,20 @@ export function getRoot<T>(response: Response): Thenable<T> {
303
303
304
304
function createPendingChunk<T>(response: Response): PendingChunk<T> {
305
305
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
306
- return new Chunk (PENDING, null, null, response);
306
+ return new ReactPromise (PENDING, null, null, response);
307
307
}
308
308
309
309
function createBlockedChunk<T>(response: Response): BlockedChunk<T> {
310
310
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
311
- return new Chunk (BLOCKED, null, null, response);
311
+ return new ReactPromise (BLOCKED, null, null, response);
312
312
}
313
313
314
314
function createErrorChunk<T>(
315
315
response: Response,
316
316
error: Error | Postpone,
317
317
): ErroredChunk<T> {
318
318
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
319
- return new Chunk (ERRORED, null, error, response);
319
+ return new ReactPromise (ERRORED, null, error, response);
320
320
}
321
321
322
322
function wakeChunk<T>(listeners: Array<(T) => mixed>, value: T): void {
@@ -390,31 +390,31 @@ function createResolvedModelChunk<T>(
390
390
value: UninitializedModel,
391
391
): ResolvedModelChunk<T> {
392
392
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
393
- return new Chunk (RESOLVED_MODEL, value, null, response);
393
+ return new ReactPromise (RESOLVED_MODEL, value, null, response);
394
394
}
395
395
396
396
function createResolvedModuleChunk<T>(
397
397
response: Response,
398
398
value: ClientReference<T>,
399
399
): ResolvedModuleChunk<T> {
400
400
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
401
- return new Chunk (RESOLVED_MODULE, value, null, response);
401
+ return new ReactPromise (RESOLVED_MODULE, value, null, response);
402
402
}
403
403
404
404
function createInitializedTextChunk(
405
405
response: Response,
406
406
value: string,
407
407
): InitializedChunk<string> {
408
408
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
409
- return new Chunk (INITIALIZED, value, null, response);
409
+ return new ReactPromise (INITIALIZED, value, null, response);
410
410
}
411
411
412
412
function createInitializedBufferChunk(
413
413
response: Response,
414
414
value: $ArrayBufferView | ArrayBuffer,
415
415
): InitializedChunk<Uint8Array> {
416
416
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
417
- return new Chunk (INITIALIZED, value, null, response);
417
+ return new ReactPromise (INITIALIZED, value, null, response);
418
418
}
419
419
420
420
function createInitializedIteratorResultChunk<T>(
@@ -423,7 +423,7 @@ function createInitializedIteratorResultChunk<T>(
423
423
done: boolean,
424
424
): InitializedChunk<IteratorResult<T, T>> {
425
425
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
426
- return new Chunk (INITIALIZED, {done: done, value: value}, null, response);
426
+ return new ReactPromise (INITIALIZED, {done: done, value: value}, null, response);
427
427
}
428
428
429
429
function createInitializedStreamChunk<
@@ -436,7 +436,7 @@ function createInitializedStreamChunk<
436
436
// We use the reason field to stash the controller since we already have that
437
437
// field. It's a bit of a hack but efficient.
438
438
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
439
- return new Chunk (INITIALIZED, value, controller, response);
439
+ return new ReactPromise (INITIALIZED, value, controller, response);
440
440
}
441
441
442
442
function createResolvedIteratorResultChunk<T>(
@@ -448,7 +448,7 @@ function createResolvedIteratorResultChunk<T>(
448
448
const iteratorResultJSON =
449
449
(done ? '{"done":true,"value":' : '{"done":false,"value":') + value + '}';
450
450
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
451
- return new Chunk (RESOLVED_MODEL, iteratorResultJSON, null, response);
451
+ return new ReactPromise (RESOLVED_MODEL, iteratorResultJSON, null, response);
452
452
}
453
453
454
454
function resolveIteratorResultChunk<T>(
@@ -1760,7 +1760,7 @@ function startAsyncIterable<T>(
1760
1760
if (nextReadIndex === buffer.length) {
1761
1761
if (closed) {
1762
1762
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
1763
- return new Chunk (
1763
+ return new ReactPromise (
1764
1764
INITIALIZED,
1765
1765
{done: true, value: undefined},
1766
1766
null,
0 commit comments