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

Method pipeThrough

lib/internal/webstreams/readablestream.js:384–429  ·  view source on GitHub ↗

* @param {ReadableWritablePair} transform * @param {StreamPipeOptions} [options] * @returns {ReadableStream}

(transform, options = kEmptyObject)

Source from the content-addressed store, hash-verified

382 * @returns {ReadableStream}
383 */
384 pipeThrough(transform, options = kEmptyObject) {
385 if (!isReadableStream(this))
386 throw new ERR_INVALID_THIS('ReadableStream');
387 const readable = transform?.readable;
388 if (!isReadableStream(readable)) {
389 throw new ERR_INVALID_ARG_TYPE(
390 'transform.readable',
391 'ReadableStream',
392 readable);
393 }
394 const writable = transform?.writable;
395 if (!isWritableStream(writable)) {
396 throw new ERR_INVALID_ARG_TYPE(
397 'transform.writable',
398 'WritableStream',
399 writable);
400 }
401
402 // The web platform tests require that these be handled one at a
403 // time and in a specific order. options can be null or undefined.
404 validateObject(options, 'options', kValidateObjectAllowObjectsAndNull);
405 const preventAbort = options?.preventAbort;
406 const preventCancel = options?.preventCancel;
407 const preventClose = options?.preventClose;
408 const signal = options?.signal;
409
410 if (signal !== undefined) {
411 validateAbortSignal(signal, 'options.signal');
412 }
413
414 if (isReadableStreamLocked(this))
415 throw new ERR_INVALID_STATE.TypeError('The ReadableStream is locked');
416 if (isWritableStreamLocked(writable))
417 throw new ERR_INVALID_STATE.TypeError('The WritableStream is locked');
418
419 const promise = readableStreamPipeTo(
420 this,
421 writable,
422 !!preventClose,
423 !!preventAbort,
424 !!preventCancel,
425 signal);
426 setPromiseHandled(promise);
427
428 return readable;
429 }
430
431 /**
432 * @param {WritableStream} destination

Callers 15

runFunction · 0.95
runFunction · 0.95
tryPipeThroughFunction · 0.95
runWebStreamFunction · 0.80
decode-utf8.any.jsFile · 0.80
encode-utf8.any.jsFile · 0.80
pipeAndAssembleFunction · 0.80

Calls 7

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

Tested by

no test coverage detected