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

Function pullWithDefaultReader

lib/internal/webstreams/readablestream.js:1882–1959  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1880 }
1881
1882 function pullWithDefaultReader() {
1883 if (isReadableStreamBYOBReader(reader)) {
1884 readableStreamBYOBReaderRelease(reader);
1885 reader = new ReadableStreamDefaultReader(stream);
1886 forwardReaderError(reader);
1887 }
1888
1889 const readRequest = {
1890 [kChunk](chunk) {
1891 queueMicrotask(() => {
1892 readAgainForBranch1 = false;
1893 readAgainForBranch2 = false;
1894 const chunk1 = chunk;
1895 let chunk2 = chunk;
1896
1897 if (!canceled1 && !canceled2) {
1898 try {
1899 chunk2 = cloneAsUint8Array(chunk);
1900 } catch (error) {
1901 readableByteStreamControllerError(
1902 branch1[kState].controller,
1903 error,
1904 );
1905 readableByteStreamControllerError(
1906 branch2[kState].controller,
1907 error,
1908 );
1909 cancelDeferred.resolve(readableStreamCancel(stream, error));
1910 return;
1911 }
1912 }
1913 if (!canceled1) {
1914 readableByteStreamControllerEnqueue(
1915 branch1[kState].controller,
1916 chunk1,
1917 );
1918 }
1919 if (!canceled2) {
1920 readableByteStreamControllerEnqueue(
1921 branch2[kState].controller,
1922 chunk2,
1923 );
1924 }
1925 reading = false;
1926
1927 if (readAgainForBranch1) {
1928 pull1Algorithm();
1929 } else if (readAgainForBranch2) {
1930 pull2Algorithm();
1931 }
1932 });
1933 },
1934 [kClose]() {
1935 reading = false;
1936
1937 if (!canceled1) {
1938 readableByteStreamControllerClose(branch1[kState].controller);
1939 }

Callers 2

pull1AlgorithmFunction · 0.85
pull2AlgorithmFunction · 0.85

Calls 3

forwardReaderErrorFunction · 0.85

Tested by

no test coverage detected