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

Function pump

lib/internal/streams/iter/broadcast.js:810–842  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

808 const signal = options?.signal;
809
810 const pump = async () => {
811 const w = result.writer;
812 try {
813 if (isAsyncIterable(input)) {
814 for await (const chunks of input) {
815 signal?.throwIfAborted();
816 if (ArrayIsArray(chunks)) {
817 if (!w.writevSync(chunks)) {
818 await w.writev(chunks, signal ? { signal } : undefined);
819 }
820 } else if (!w.writeSync(chunks)) {
821 await w.write(chunks, signal ? { signal } : undefined);
822 }
823 }
824 } else if (isSyncIterable(input)) {
825 for (const chunks of input) {
826 signal?.throwIfAborted();
827 if (ArrayIsArray(chunks)) {
828 if (!w.writevSync(chunks)) {
829 await w.writev(chunks, signal ? { signal } : undefined);
830 }
831 } else if (!w.writeSync(chunks)) {
832 await w.write(chunks, signal ? { signal } : undefined);
833 }
834 }
835 }
836 if (w.endSync() < 0) {
837 await w.end(signal ? { signal } : undefined);
838 }
839 } catch (error) {
840 w.fail(wrapError(error));
841 }
842 };
843 PromisePrototypeThen(pump(), undefined, () => {});
844
845 return result;

Callers 1

fromFunction · 0.70

Calls 11

wrapErrorFunction · 0.85
throwIfAbortedMethod · 0.80
isAsyncIterableFunction · 0.70
isSyncIterableFunction · 0.70
writevSyncMethod · 0.45
writevMethod · 0.45
writeSyncMethod · 0.45
writeMethod · 0.45
endSyncMethod · 0.45
endMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…