Skip to content

Commit

Permalink
Merge branch 'master' into annevk/blob-constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres committed May 16, 2019
2 parents fb9508f + 9977ce8 commit abb6af3
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Closes #???

The following tasks have been completed:

* [ ] Confirmed there are no ReSpec/BikeShed errors or warnings.
* [ ] Modified Web platform tests (link to pull request)

Implementation commitment:

* [ ] WebKit (https://bugs.webkit.org/show_bug.cgi?id=)
* [ ] Chromium (https://bugs.chromium.org/p/chromium/issues/detail?id=)
* [ ] Gecko (https://bugzilla.mozilla.org/show_bug.cgi?id=)
40 changes: 40 additions & 0 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ spec: url
text: url; for:/
type: interface
text: URL
spec: fetch
type:interface
text:ReadableStream
</pre>

<pre class="anchors">
Expand Down Expand Up @@ -228,6 +231,11 @@ interface Blob {
Blob slice(optional [Clamp] long long start,
optional [Clamp] long long end,
optional DOMString contentType);

// read from the Blob.
[NewObject] ReadableStream stream();
[NewObject] Promise<USVString> text();
[NewObject] Promise<ArrayBuffer> arrayBuffer();
};

enum EndingType { "transparent", "native" };
Expand Down Expand Up @@ -554,6 +562,38 @@ It must act as follows:
</pre>
</div>

### The {{Blob/stream()}} method ### {#stream-method-algo}

The <dfn method for=Blob>stream()</dfn> method, when invoked, must return
the result of calling [=get stream=] on the [=context object=].

### The {{Blob/text()}} method ### {#text-method-algo}

The <dfn method for=Blob>text()</dfn> method, when invoked, must run these steps:

1. Let |stream| be the result of calling [=get stream=] on the [=context object=].
1. Let |reader| be the result of [=get a reader|getting a reader=] from |stream|.
If that threw an exception, return a new promise rejected with that exception.
1. Let |promise| be the result of [=read all bytes|reading all bytes=] from |stream| with |reader|.
1. Return the result of transforming |promise| by a fulfillment handler that returns the result of
running [=UTF-8 decode=] on its first argument.

Note: This is different from the behavior of {{FileReader/readAsText()}} to align better
with the behavior of {{Body/text()|Fetch's text()}}. Specifically this method will always
use UTF-8 as encoding, while {{FileReader}} can use a different encoding depending on
the blob's type and passed in encoding name.

### The {{Blob/arrayBuffer()}} method ### {#arraybuffer-method-algo}

The <dfn method for=Blob>arrayBuffer()</dfn> method, when invoked, must run these steps:

1. Let |stream| be the result of calling [=get stream=] on the [=context object=].
1. Let |reader| be the result of [=get a reader|getting a reader=] from |stream|.
If that threw an exception, return a new promise rejected with that exception.
1. Let |promise| be the result of [=read all bytes|reading all bytes=] from |stream| with |reader|.
1. Return the result of transforming |promise| by a fulfillment handler that returns
a new {{ArrayBuffer}} whose contents are its first argument.

<!--
████████ ████ ██ ████████
██ ██ ██ ██
Expand Down
4 changes: 2 additions & 2 deletions w3c.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"group": [
"83482"
"114929"
],
"contacts": [
"siusin"
],
"shortName": "FileAPI",
"repo-type": "rec-track"
}
}

0 comments on commit abb6af3

Please sign in to comment.