MCPcopy Index your code
hub / github.com/nodejs/node / pullWithBYOBReader

Function pullWithBYOBReader

lib/internal/webstreams/readablestream.js:1961–2059  ·  view source on GitHub ↗
(view, forBranch2)

Source from the content-addressed store, hash-verified

1959 }
1960
1961 function pullWithBYOBReader(view, forBranch2) {
1962 if (isReadableStreamDefaultReader(reader)) {
1963 readableStreamDefaultReaderRelease(reader);
1964 reader = new ReadableStreamBYOBReader(stream);
1965 forwardReaderError(reader);
1966 }
1967
1968 const byobBranch = forBranch2 === true ? branch2 : branch1;
1969 const otherBranch = forBranch2 === false ? branch2 : branch1;
1970 const readIntoRequest = {
1971 [kChunk](chunk) {
1972 queueMicrotask(() => {
1973 readAgainForBranch1 = false;
1974 readAgainForBranch2 = false;
1975 const byobCanceled = forBranch2 === true ? canceled2 : canceled1;
1976 const otherCanceled = forBranch2 === false ? canceled2 : canceled1;
1977
1978 if (!otherCanceled) {
1979 let clonedChunk;
1980
1981 try {
1982 clonedChunk = cloneAsUint8Array(chunk);
1983 } catch (error) {
1984 readableByteStreamControllerError(
1985 byobBranch[kState].controller,
1986 error,
1987 );
1988 readableByteStreamControllerError(
1989 otherBranch[kState].controller,
1990 error,
1991 );
1992 cancelDeferred.resolve(readableStreamCancel(stream, error));
1993 return;
1994 }
1995 if (!byobCanceled) {
1996 readableByteStreamControllerRespondWithNewView(
1997 byobBranch[kState].controller,
1998 chunk,
1999 );
2000 }
2001
2002 readableByteStreamControllerEnqueue(
2003 otherBranch[kState].controller,
2004 clonedChunk,
2005 );
2006 } else if (!byobCanceled) {
2007 readableByteStreamControllerRespondWithNewView(
2008 byobBranch[kState].controller,
2009 chunk,
2010 );
2011 }
2012 reading = false;
2013
2014 if (readAgainForBranch1) {
2015 pull1Algorithm();
2016 } else if (readAgainForBranch2) {
2017 pull2Algorithm();
2018 }

Callers 2

pull1AlgorithmFunction · 0.85
pull2AlgorithmFunction · 0.85

Calls 3

forwardReaderErrorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…