@@ -65,6 +65,9 @@ spec: url
6565 text: url; for:/
6666 type: interface
6767 text: URL
68+ spec: fetch
69+ type:interface
70+ text:ReadableStream
6871</pre>
6972
7073<pre class="anchors">
@@ -228,6 +231,11 @@ interface Blob {
228231 Blob slice(optional [Clamp] long long start,
229232 optional [Clamp] long long end,
230233 optional DOMString contentType);
234+
235+ // read from the Blob.
236+ [NewObject] ReadableStream stream();
237+ [NewObject] Promise<USVString> text();
238+ [NewObject] Promise<ArrayBuffer> arrayBuffer();
231239};
232240
233241enum EndingType { "transparent", "native" };
@@ -554,6 +562,38 @@ It must act as follows:
554562 </pre>
555563</div>
556564
565+ ### The {{Blob/stream()}} method ### {#stream-method-algo}
566+
567+ The <dfn method for=Blob>stream()</dfn> method, when invoked, must return
568+ the result of calling [=get stream=] on the [=context object=] .
569+
570+ ### The {{Blob/text()}} method ### {#text-method-algo}
571+
572+ The <dfn method for=Blob>text()</dfn> method, when invoked, must run these steps:
573+
574+ 1. Let |stream| be the result of calling [=get stream=] on the [=context object=] .
575+ 1. Let |reader| be the result of [=get a reader|getting a reader=] from |stream|.
576+ If that threw an exception, return a new promise rejected with that exception.
577+ 1. Let |promise| be the result of [=read all bytes|reading all bytes=] from |stream| with |reader|.
578+ 1. Return the result of transforming |promise| by a fulfillment handler that returns the result of
579+ running [=UTF-8 decode=] on its first argument.
580+
581+ Note: This is different from the behavior of {{FileReader/readAsText()}} to align better
582+ with the behavior of {{Body/text()|Fetch's text()}} . Specifically this method will always
583+ use UTF-8 as encoding, while {{FileReader}} can use a different encoding depending on
584+ the blob's type and passed in encoding name.
585+
586+ ### The {{Blob/arrayBuffer()}} method ### {#arraybuffer-method-algo}
587+
588+ The <dfn method for=Blob>arrayBuffer()</dfn> method, when invoked, must run these steps:
589+
590+ 1. Let |stream| be the result of calling [=get stream=] on the [=context object=] .
591+ 1. Let |reader| be the result of [=get a reader|getting a reader=] from |stream|.
592+ If that threw an exception, return a new promise rejected with that exception.
593+ 1. Let |promise| be the result of [=read all bytes|reading all bytes=] from |stream| with |reader|.
594+ 1. Return the result of transforming |promise| by a fulfillment handler that returns
595+ a new {{ArrayBuffer}} whose contents are its first argument.
596+
557597<!--
558598████████ ████ ██ ████████
559599██ ██ ██ ██
0 commit comments