Re: Overlap between StreamReader and FileReader

On Wed, Jul 10, 2013 at 7:02 AM, Anne van Kesteren <annevk@annevk.nl> wrote:
> On Tue, Jul 2, 2013 at 12:21 AM, Takeshi Yoshino <tyoshino@google.com> wrote:
>> What I have in my mind is like this:
>>
>> if (this.readyState == this.LOADING) {
>>   stream = xhr.response;
>>   // XHR has already written some data x0 to stream
>>   stream.read().progress(progressHandler);
>> }
>>
>> ...loop...
>>
>> // XHR writes data x1 to stream
>> // XHR writes data x2 to stream
>> // XHR finishes writing to stream
>>
>> progressHandler continues receiving data till EOF. For this read() call
>> without maxSize, all of x0, x1 and x2 will be passed to progressHandler.
>
> I see. I kinda thought that if you omitted size it would just give you
> everything in stream's buffer and not everything until end-of-stream.

If you just want to be notified about data as it comes in you can use
read*Chunked() in my proposal.

Polling data from the buffer seems less useful.

>>> Do we even need that? It seems just passing ArrayBuffer in and out
>>> could be sufficient for now?
>>
>> As one of read()'s arguments?
>
> As for what it would return. Or do we have use cases where decoding to
> strings and/or Blobs are important?

Reading any format that contains textual data. I.e. things like HTML,
OpenDocument, pdf, etc. While many of those are compressed, it seems
likely that you could pass a stream through a decompressor which
produces a decompressed stream.

/ Jonas

Received on Wednesday, 17 July 2013 06:11:42 UTC