From fb6e6054086f903a570bd4ec73729b18c1ec870c Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Mon, 29 Jun 2026 10:31:16 +0200 Subject: [PATCH] stream: expose ReadableStreamTee Signed-off-by: Matteo Collina --- doc/api/webstreams.md | 20 ++++++++++++++++++ lib/stream/web.js | 21 +++++++++++++++++++ test/parallel/test-whatwg-readablestream.js | 23 +++++++++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/doc/api/webstreams.md b/doc/api/webstreams.md index 55b27584361e1c..5108c80d4303cf 100644 --- a/doc/api/webstreams.md +++ b/doc/api/webstreams.md @@ -106,6 +106,26 @@ For more details refer to the relevant documentation: ## API +### `ReadableStreamTee(stream[, cloneForBranch2])` + + + +* `stream` {ReadableStream} +* `cloneForBranch2` {boolean} When `true`, chunks enqueued into the second + branch are cloned from chunks enqueued into the first branch. **Default:** + `false`. +* Returns: {ReadableStream\[]} Two {ReadableStream} branches. + +Runs the WHATWG `ReadableStreamTee` abstract operation on `stream`. + +This differs from `readableStream.tee()` only when `cloneForBranch2` is +`true`. The `tee()` method always passes `false`, while other web platform +specifications, such as Fetch body cloning, pass `true` so that the second +branch receives cloned chunks and consumption of one branch cannot mutate chunks +seen by the other. + ### Class: `ReadableStream`