( stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, autoAllocateChunkSize)
| 3466 | } |
| 3467 | |
| 3468 | function setupReadableByteStreamController( |
| 3469 | stream, |
| 3470 | controller, |
| 3471 | startAlgorithm, |
| 3472 | pullAlgorithm, |
| 3473 | cancelAlgorithm, |
| 3474 | highWaterMark, |
| 3475 | autoAllocateChunkSize) { |
| 3476 | assert(stream[kState].controller === undefined); |
| 3477 | if (autoAllocateChunkSize !== undefined) { |
| 3478 | assert(NumberIsInteger(autoAllocateChunkSize)); |
| 3479 | assert(autoAllocateChunkSize > 0); |
| 3480 | } |
| 3481 | controller[kState] = { |
| 3482 | byobRequest: null, |
| 3483 | closeRequested: false, |
| 3484 | pullAgain: false, |
| 3485 | pulling: false, |
| 3486 | pullFulfilled: undefined, |
| 3487 | pullRejected: undefined, |
| 3488 | started: false, |
| 3489 | stream, |
| 3490 | queue: [], |
| 3491 | queueTotalSize: 0, |
| 3492 | highWaterMark, |
| 3493 | pullAlgorithm, |
| 3494 | cancelAlgorithm, |
| 3495 | autoAllocateChunkSize, |
| 3496 | pendingPullIntos: [], |
| 3497 | }; |
| 3498 | stream[kState].controller = controller; |
| 3499 | |
| 3500 | const startResult = startAlgorithm(); |
| 3501 | |
| 3502 | if (startResult === null || |
| 3503 | (typeof startResult !== 'object' && typeof startResult !== 'function')) { |
| 3504 | // See setupReadableStreamDefaultController. |
| 3505 | queueMicrotask(() => { |
| 3506 | controller[kState].started = true; |
| 3507 | assert(!controller[kState].pulling); |
| 3508 | assert(!controller[kState].pullAgain); |
| 3509 | readableByteStreamControllerCallPullIfNeeded(controller); |
| 3510 | }); |
| 3511 | return; |
| 3512 | } |
| 3513 | |
| 3514 | PromisePrototypeThen( |
| 3515 | new Promise((r) => r(startResult)), |
| 3516 | () => { |
| 3517 | controller[kState].started = true; |
| 3518 | assert(!controller[kState].pulling); |
| 3519 | assert(!controller[kState].pullAgain); |
| 3520 | readableByteStreamControllerCallPullIfNeeded(controller); |
| 3521 | }, |
| 3522 | (error) => readableByteStreamControllerError(controller, error)); |
| 3523 | } |
| 3524 | |
| 3525 | function setupReadableByteStreamControllerFromSource( |
no test coverage detected
searching dependent graphs…