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

Function pumpToWeb

lib/internal/streams/pipeline.js:153–180  ·  view source on GitHub ↗
(readable, writable, finish, { end })

Source from the content-addressed store, hash-verified

151}
152
153async function pumpToWeb(readable, writable, finish, { end }) {
154 if (isTransformStream(writable)) {
155 writable = writable.writable;
156 }
157 // https://streams.spec.whatwg.org/#example-manual-write-with-backpressure
158 const writer = writable.getWriter();
159 try {
160 for await (const chunk of readable) {
161 await writer.ready;
162 writer.write(chunk).catch(() => {});
163 }
164
165 await writer.ready;
166
167 if (end) {
168 await writer.close();
169 }
170
171 finish();
172 } catch (err) {
173 try {
174 await writer.abort(err);
175 finish(err);
176 } catch (err) {
177 finish(err);
178 }
179 }
180}
181
182function pipeline(...streams) {
183 return pipelineImpl(streams, once(popCallback(streams)));

Callers 1

pipelineImplFunction · 0.85

Calls 6

isTransformStreamFunction · 0.85
getWriterMethod · 0.80
finishFunction · 0.70
closeMethod · 0.65
abortMethod · 0.65
writeMethod · 0.45

Tested by

no test coverage detected