* @param {ReadableWritablePair} transform * @param {StreamPipeOptions} [options] * @returns {ReadableStream}
(transform, options = kEmptyObject)
| 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 |
no test coverage detected