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

Method pipeTo

lib/internal/webstreams/readablestream.js:436–472  ·  view source on GitHub ↗

* @param {WritableStream} destination * @param {StreamPipeOptions} [options] * @returns {Promise }

(destination, options = kEmptyObject)

Source from the content-addressed store, hash-verified

434 * @returns {Promise<void>}
435 */
436 pipeTo(destination, options = kEmptyObject) {
437 try {
438 if (!isReadableStream(this))
439 throw new ERR_INVALID_THIS('ReadableStream');
440 if (!isWritableStream(destination)) {
441 throw new ERR_INVALID_ARG_TYPE(
442 'transform.writable',
443 'WritableStream',
444 destination);
445 }
446
447 validateObject(options, 'options', kValidateObjectAllowObjectsAndNull);
448 const preventAbort = options?.preventAbort;
449 const preventCancel = options?.preventCancel;
450 const preventClose = options?.preventClose;
451 const signal = options?.signal;
452
453 if (signal !== undefined) {
454 validateAbortSignal(signal, 'options.signal');
455 }
456
457 if (isReadableStreamLocked(this))
458 throw new ERR_INVALID_STATE.TypeError('The ReadableStream is locked');
459 if (isWritableStreamLocked(destination))
460 throw new ERR_INVALID_STATE.TypeError('The WritableStream is locked');
461
462 return readableStreamPipeTo(
463 this,
464 destination,
465 !!preventClose,
466 !!preventAbort,
467 !!preventCancel,
468 signal);
469 } catch (error) {
470 return PromiseReject(error);
471 }
472 }
473
474 /**
475 * @returns {ReadableStream[]}

Callers 7

mainFunction · 0.95
runFunction · 0.95
runFunction · 0.95
runFunction · 0.45
runFunction · 0.45
runFunction · 0.45
runFunction · 0.45

Calls 6

isWritableStreamFunction · 0.85
validateAbortSignalFunction · 0.85
isReadableStreamLockedFunction · 0.85
isWritableStreamLockedFunction · 0.85
readableStreamPipeToFunction · 0.85
isReadableStreamFunction · 0.50

Tested by

no test coverage detected