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

Function pullWithBYOBReader

out/cli.cjs:13644–13711  ·  view source on GitHub ↗
(view, forBranch2)

Source from the content-addressed store, hash-verified

13642 ReadableStreamDefaultReaderRead(reader, readRequest);
13643 }
13644 function pullWithBYOBReader(view, forBranch2) {
13645 if (IsReadableStreamDefaultReader(reader)) {
13646 ReadableStreamReaderGenericRelease(reader);
13647 reader = AcquireReadableStreamBYOBReader(stream4);
13648 forwardReaderError(reader);
13649 }
13650 const byobBranch = forBranch2 ? branch2 : branch1;
13651 const otherBranch = forBranch2 ? branch1 : branch2;
13652 const readIntoRequest = {
13653 _chunkSteps: (chunk) => {
13654 _queueMicrotask(() => {
13655 readAgainForBranch1 = false;
13656 readAgainForBranch2 = false;
13657 const byobCanceled = forBranch2 ? canceled2 : canceled1;
13658 const otherCanceled = forBranch2 ? canceled1 : canceled2;
13659 if (!otherCanceled) {
13660 let clonedChunk;
13661 try {
13662 clonedChunk = CloneAsUint8Array(chunk);
13663 } catch (cloneE) {
13664 ReadableByteStreamControllerError(byobBranch._readableStreamController, cloneE);
13665 ReadableByteStreamControllerError(otherBranch._readableStreamController, cloneE);
13666 resolveCancelPromise(ReadableStreamCancel(stream4, cloneE));
13667 return;
13668 }
13669 if (!byobCanceled) {
13670 ReadableByteStreamControllerRespondWithNewView(byobBranch._readableStreamController, chunk);
13671 }
13672 ReadableByteStreamControllerEnqueue(otherBranch._readableStreamController, clonedChunk);
13673 } else if (!byobCanceled) {
13674 ReadableByteStreamControllerRespondWithNewView(byobBranch._readableStreamController, chunk);
13675 }
13676 reading = false;
13677 if (readAgainForBranch1) {
13678 pull1Algorithm();
13679 } else if (readAgainForBranch2) {
13680 pull2Algorithm();
13681 }
13682 });
13683 },
13684 _closeSteps: (chunk) => {
13685 reading = false;
13686 const byobCanceled = forBranch2 ? canceled2 : canceled1;
13687 const otherCanceled = forBranch2 ? canceled1 : canceled2;
13688 if (!byobCanceled) {
13689 ReadableByteStreamControllerClose(byobBranch._readableStreamController);
13690 }
13691 if (!otherCanceled) {
13692 ReadableByteStreamControllerClose(otherBranch._readableStreamController);
13693 }
13694 if (chunk !== void 0) {
13695 if (!byobCanceled) {
13696 ReadableByteStreamControllerRespondWithNewView(byobBranch._readableStreamController, chunk);
13697 }
13698 if (!otherCanceled && otherBranch._readableStreamController._pendingPullIntos.length > 0) {
13699 ReadableByteStreamControllerRespond(otherBranch._readableStreamController, 0);
13700 }
13701 }

Callers 2

pull1AlgorithmFunction · 0.85
pull2AlgorithmFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…