Skip to content

Implement textStream method in Blob interface#221

Open
noamr wants to merge 1 commit into
w3c:mainfrom
noamr:patch-1
Open

Implement textStream method in Blob interface#221
noamr wants to merge 1 commit into
w3c:mainfrom
noamr:patch-1

Conversation

@noamr
Copy link
Copy Markdown

@noamr noamr commented May 17, 2026

Add textStream method to Blob interface for streaming text.

Part of whatwg/fetch#1861

For normative changes, the following tasks have been completed:

  • Modified Web platform tests (link to pull request)

Implementation commitment:


Preview | Diff

Add textStream method to Blob interface for streaming text.
@noamr
Copy link
Copy Markdown
Author

noamr commented May 17, 2026

Corresponding to whatwg/fetch#1862

Comment thread index.bs
### The {{Blob/textStream()}} method ### {#text-stream-method-algo}

The <dfn method for=Blob>textStream()</dfn> method, when invoked, must return
the result of calling [=get stream=] on [=this=], [=pipe through|piped through=] a new {{TextDecoderStream}} object.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the Fetch PR we probably don't want to call this constructor directly.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea will continue this once we resolve on how to do this for fetch.

Comment thread index.bs
[NewObject] ReadableStream stream();
[NewObject] Promise<USVString> text();
[NewObject] Promise<ArrayBuffer> arrayBuffer();
[NewObject] ReadableStream textStream();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a conscious decision not to do something like stream({ mode: "text" }) or such?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What other modes do you envision we'd add?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What other modes do you envision we'd add?

anything that's in a form of transform stream, like compression/decompression? Not pushing for it, just thinking if .stream().pipeThrough(new TextDecoderStream()) is too long, then logically that applies to other transform streams too.

But seems this was a conscious choice - I'm ok with it too.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that Response (and Request) don't have a stream() method. In general I prefer individual methods over multiple method definitions packed in a dictionary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants