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