From 01502224ab1a3fcb8ef97483400fb2c19977b3ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20J=C3=A4genstedt?= Date: Thu, 2 Oct 2025 14:08:56 +0200 Subject: [PATCH] Add a textStream() method to the Body mixin Fixes https://github.com/whatwg/fetch/issues/1861. --- fetch.bs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fetch.bs b/fetch.bs index 122efc771..fa2e9bac5 100755 --- a/fetch.bs +++ b/fetch.bs @@ -8032,6 +8032,7 @@ interface mixin Body { [NewObject] Promise<FormData> formData(); [NewObject] Promise<any> json(); [NewObject] Promise<USVString> text(); + [NewObject] ReadableStream textStream(); };

Formats you would not want a network layer to be dependent upon, such as @@ -8073,6 +8074,9 @@ due course.

requestOrResponse . text()

Returns a promise fulfilled with requestOrResponse's body as string. + +

requestOrResponse . textStream() +

Returns a {{ReadableStream}} with requestOrResponse's body as string chunks.


@@ -8246,6 +8250,20 @@ of running consume body with this and parse JSON from of running consume body with this and UTF-8 decode. +
+

The textStream() method steps are:

+ +
    +
  1. If this's body is null, throw a {{TypeError}}. + +

  2. Let stream be this's body's stream. + +

  3. Let decoder be a new {{TextDecoderStream}} object. + +

  4. Return the result of piping stream through decoder. +

+
+

Request class