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

Function pump

lib/internal/streams/operators.js:94–145  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

92 }
93
94 async function pump() {
95 try {
96 for await (let val of stream) {
97 if (done) {
98 return;
99 }
100
101 if (signal.aborted) {
102 throw new AbortError();
103 }
104
105 try {
106 val = fn(val, signalOpt);
107
108 if (val === kEmpty) {
109 continue;
110 }
111
112 val = PromiseResolve(val);
113 } catch (err) {
114 val = PromiseReject(err);
115 }
116
117 cnt += 1;
118
119 PromisePrototypeThen(val, afterItemProcessed, onCatch);
120
121 queue.push(val);
122 if (next) {
123 next();
124 next = null;
125 }
126
127 if (!done && (queue.length >= highWaterMark || cnt >= concurrency)) {
128 await new Promise((resolve) => {
129 resume = resolve;
130 });
131 }
132 }
133 queue.push(kEof);
134 } catch (err) {
135 const val = PromiseReject(err);
136 PromisePrototypeThen(val, afterItemProcessed, onCatch);
137 queue.push(val);
138 } finally {
139 done = true;
140 if (next) {
141 next();
142 next = null;
143 }
144 }
145 }
146
147 pump();
148

Callers 1

mapFunction · 0.70

Calls 3

nextFunction · 0.70
fnFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…