@@ -65,6 +65,9 @@ spec: url
65
65
text: url; for:/
66
66
type: interface
67
67
text: URL
68
+ spec: fetch
69
+ type:interface
70
+ text:ReadableStream
68
71
</pre>
69
72
70
73
<pre class="anchors">
@@ -228,6 +231,11 @@ interface Blob {
228
231
Blob slice(optional [Clamp] long long start,
229
232
optional [Clamp] long long end,
230
233
optional DOMString contentType);
234
+
235
+ // read from the Blob.
236
+ [NewObject] ReadableStream stream();
237
+ [NewObject] Promise<USVString> text();
238
+ [NewObject] Promise<ArrayBuffer> arrayBuffer();
231
239
};
232
240
233
241
enum EndingType { "transparent", "native" };
@@ -554,6 +562,38 @@ It must act as follows:
554
562
</pre>
555
563
</div>
556
564
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
+
557
597
<!--
558
598
████████ ████ ██ ████████
559
599
██ ██ ██ ██
0 commit comments