Skip to content

Commit cd1d1da

Browse files
authored
Add textStream() method to Blob interface (#221)
* Implement textStream method in Blob interface Add textStream method to Blob interface for streaming text.
1 parent 13757c2 commit cd1d1da

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

index.bs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ interface Blob {
300300
[NewObject] ReadableStream stream();
301301
[NewObject] Promise<USVString> text();
302302
[NewObject] Promise<ArrayBuffer> arrayBuffer();
303+
[NewObject] ReadableStream textStream();
303304
[NewObject] Promise<Uint8Array> bytes();
304305
};
305306

@@ -644,6 +645,16 @@ The <dfn method for=Blob>bytes()</dfn> method, when invoked, must run these step
644645
1. Return the result of transforming |promise| by a fulfillment handler that returns
645646
a new {{Uint8Array}} wrapping an {{ArrayBuffer}} containing its first argument.
646647

648+
### The {{Blob/textStream()}} method ### {#text-stream-method-algo}
649+
650+
The <dfn method for=Blob>textStream()</dfn> method steps are:
651+
652+
1. Let |stream| be the result of calling [=get stream=] on [=this=].
653+
1. Let |decoder| be a new {{TextDecoderStream}} in [=this=]'s [=relevant realm=].
654+
1. [=set up a text decoder stream|Set up=] |decoder| with [=UTF-8=].
655+
1. Return the result of calling |stream|, [=pipe through|piped through=] |decoder|.
656+
657+
Note: This differs from {{FileReader/readAsText()}} in that it always uses the [=UTF-8=] encoding.
647658
<!--
648659
████████ ████ ██ ████████
649660
██ ██ ██ ██

0 commit comments

Comments
 (0)