Skip to content

Commit abb6af3

Browse files
Merge branch 'master' into annevk/blob-constructor
2 parents fb9508f + 9977ce8 commit abb6af3

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Closes #???
2+
3+
The following tasks have been completed:
4+
5+
* [ ] Confirmed there are no ReSpec/BikeShed errors or warnings.
6+
* [ ] Modified Web platform tests (link to pull request)
7+
8+
Implementation commitment:
9+
10+
* [ ] WebKit (https://bugs.webkit.org/show_bug.cgi?id=)
11+
* [ ] Chromium (https://bugs.chromium.org/p/chromium/issues/detail?id=)
12+
* [ ] Gecko (https://bugzilla.mozilla.org/show_bug.cgi?id=)

index.bs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

233241
enum 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
██ ██ ██ ██

w3c.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"group": [
3-
"83482"
3+
"114929"
44
],
55
"contacts": [
66
"siusin"
77
],
88
"shortName": "FileAPI",
99
"repo-type": "rec-track"
10-
}
10+
}

0 commit comments

Comments
 (0)