MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / ReadableByteStreamControllerPullInto

Function ReadableByteStreamControllerPullInto

out/cli.cjs:11508–11559  ·  view source on GitHub ↗
(controller, view, min, readIntoRequest)

Source from the content-addressed store, hash-verified

11506 }
11507 }
11508 function ReadableByteStreamControllerPullInto(controller, view, min, readIntoRequest) {
11509 const stream4 = controller._controlledReadableByteStream;
11510 const ctor = view.constructor;
11511 const elementSize = arrayBufferViewElementSize(ctor);
11512 const { byteOffset, byteLength } = view;
11513 const minimumFill = min * elementSize;
11514 let buffer;
11515 try {
11516 buffer = TransferArrayBuffer(view.buffer);
11517 } catch (e3) {
11518 readIntoRequest._errorSteps(e3);
11519 return;
11520 }
11521 const pullIntoDescriptor = {
11522 buffer,
11523 bufferByteLength: buffer.byteLength,
11524 byteOffset,
11525 byteLength,
11526 bytesFilled: 0,
11527 minimumFill,
11528 elementSize,
11529 viewConstructor: ctor,
11530 readerType: "byob"
11531 };
11532 if (controller._pendingPullIntos.length > 0) {
11533 controller._pendingPullIntos.push(pullIntoDescriptor);
11534 ReadableStreamAddReadIntoRequest(stream4, readIntoRequest);
11535 return;
11536 }
11537 if (stream4._state === "closed") {
11538 const emptyView = new ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, 0);
11539 readIntoRequest._closeSteps(emptyView);
11540 return;
11541 }
11542 if (controller._queueTotalSize > 0) {
11543 if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor)) {
11544 const filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
11545 ReadableByteStreamControllerHandleQueueDrain(controller);
11546 readIntoRequest._chunkSteps(filledView);
11547 return;
11548 }
11549 if (controller._closeRequested) {
11550 const e3 = new TypeError("Insufficient bytes to fill elements in the given buffer");
11551 ReadableByteStreamControllerError(controller, e3);
11552 readIntoRequest._errorSteps(e3);
11553 return;
11554 }
11555 }
11556 controller._pendingPullIntos.push(pullIntoDescriptor);
11557 ReadableStreamAddReadIntoRequest(stream4, readIntoRequest);
11558 ReadableByteStreamControllerCallPullIfNeeded(controller);
11559 }
11560 function ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) {
11561 if (firstDescriptor.readerType === "none") {
11562 ReadableByteStreamControllerShiftPendingPullInto(controller);

Callers 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…