summaryrefslogtreecommitdiff
path: root/op_crates/fetch
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2021-01-26 21:56:29 +1100
committerGitHub <noreply@github.com>2021-01-26 21:56:29 +1100
commitf9949a31707dcaa5a8786bfe4f84ed202be91607 (patch)
tree08a4785f80292a05593918f648c1740f42ee9512 /op_crates/fetch
parent8b6893438ade5031640576f44ac4ce71a384c5b9 (diff)
fix(op_crates/fetch): fix ReadableStream.pipeThrough() (#9265)
Fixes #9252
Diffstat (limited to 'op_crates/fetch')
-rw-r--r--op_crates/fetch/11_streams.js22
1 files changed, 18 insertions, 4 deletions
diff --git a/op_crates/fetch/11_streams.js b/op_crates/fetch/11_streams.js
index 827f8c232..b7a9acca0 100644
--- a/op_crates/fetch/11_streams.js
+++ b/op_crates/fetch/11_streams.js
@@ -3136,21 +3136,35 @@
* @returns {ReadableStream<T>}
*/
pipeThrough(
- { readable, writable },
+ transform,
{ preventClose, preventAbort, preventCancel, signal } = {},
) {
+ if (!isReadableStream(this)) {
+ throw new TypeError("this must be a ReadableStream");
+ }
+ const { readable } = transform;
+ if (!isReadableStream(readable)) {
+ throw new TypeError("readable must be a ReadableStream");
+ }
+ const { writable } = transform;
+ if (!isWritableStream(writable)) {
+ throw new TypeError("writable must be a WritableStream");
+ }
if (isReadableStreamLocked(this)) {
throw new TypeError("ReadableStream is already locked.");
}
+ if (signal !== undefined && !(signal instanceof AbortSignal)) {
+ throw new TypeError("signal must be an AbortSignal");
+ }
if (isWritableStreamLocked(writable)) {
throw new TypeError("Target WritableStream is already locked.");
}
const promise = readableStreamPipeTo(
this,
writable,
- preventClose,
- preventAbort,
- preventCancel,
+ Boolean(preventClose),
+ Boolean(preventAbort),
+ Boolean(preventCancel),
signal,
);
setPromiseIsHandledToTrue(promise);