Re: [whatwg/fetch] Add a textStream() method to the Body mixin (PR #1862)

@annevk commented on this pull request.



> @@ -8246,6 +8250,20 @@ of running <a for=Body>consume body</a> with <a>this</a> and <a>parse JSON from
 of running <a for=Body>consume body</a> with <a>this</a> and <a>UTF-8 decode</a>.
 </div>
 
+<div algorithm>
+<p>The <dfn method for=Body><code>textStream()</code></dfn> method steps are:</p>

I think for the null case it'd be nicer to return an empty stream, similar to what `text()` does.

Another thing that's not entirely clear to me is whether piping ends up making the underlying stream unusable so that you can't invoke `text()` after `textStream()` for instance. (That's a property we want.)

> @@ -8246,6 +8250,20 @@ of running <a for=Body>consume body</a> with <a>this</a> and <a>parse JSON from
 of running <a for=Body>consume body</a> with <a>this</a> and <a>UTF-8 decode</a>.
 </div>
 
+<div algorithm>
+<p>The <dfn method for=Body><code>textStream()</code></dfn> method steps are:</p>
+
+<ol>
+ <li><p>If <span>this</span>'s <a for=Body>body</a> is null, throw a {{TypeError}}.
+
+ <li><p>Let <var>stream</var> be <a>this</a>'s <a for=Body>body</a>'s <a for=body>stream</a>.
+
+ <li><p>Let <var>decoder</var> be a new {{TextDecoderStream}} object.

@MattiasBuelens or @ricea might have thoughts, but ideally we don't use public API for internal algorithms.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/pull/1862#pullrequestreview-3294579768
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fetch/pull/1862/review/3294579768@github.com>

Received on Thursday, 2 October 2025 13:20:34 UTC