Skip to content

Commit

Permalink
Rebase to match FileReader changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkruisselbrink committed Mar 15, 2019
1 parent d0b650a commit 1b65277
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -572,45 +572,34 @@ It must act as follows:
### The {{Blob/stream()}} method ### {#stream-method-algo}

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

To <dfn lt="get a stream for a Blob|getting a stream for a Blob">get a stream for a {{Blob}}</dfn>
|blob|, run the following steps:

1. Let |stream| be the result of [=construct a ReadableStream object|constructing=] a
{{ReadableStream}} object.
1. Run the following steps [=in parallel=]:
1. While not all bytes of |blob| have been read:
1. Let |bytes| be the byte sequence that results from reading a [=chunk=] from |blob|.
1. If a [=file read error=] occured while reading |bytes|, [$ReadableStream/error$]
|stream| with a [=failure reason=] and abort these steps.
1. [=ReadableStream/Enqueue=] |bytes| into |stream|.

Issue: We need to specify more concretely what reading from a Blob actually does,
and what possible errors can happen.
1. Return |stream|.
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 the result of [=getting a stream for a Blob=] for the [=context object=].
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()|Body.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 the result of [=getting a stream for a Blob=] for the [=context object=].
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.
a new {{ArrayBuffer}} whose contents are its first argument.

<!--
████████ ████ ██ ████████
Expand Down

0 comments on commit 1b65277

Please sign in to comment.