Re: Overlap between StreamReader and FileReader

On Fri, May 17, 2013 at 12:09 PM, Takeshi Yoshino <tyoshino@google.com> wrote:
> I thought the spec is clear about this but sorry it isn't. In the spec we
> should say that StreamReader invalidates consumed data in Stream and buffer
> for the invalidated bytes will be released at that point. Right?

I'm glad we're all getting on the same page now. I think there might
be use cases for a Blob without size (i.e. where you do not discard
the data after consuming) which is what Stream seems to be today, but
I'm not sure we should call that Stream.

And I think for XMLHttpRequest at least we want an API where data can
be discarded once processed so you do not have to keep multi-megabyte
sound files on disk if all you want is to provide a (potentially
post-processed) live stream.


> I wanted to understand clearly what you meant by "discard" in your posts. I
> wondered if you were suggesting that we have some method to skip incoming
> data without creating any object holding received data. I.e. something like
>
> s.skip(10);
> s.readFrom(10);
>
> not like
>
> var useless_data_at_head_remaining = 256;
> ondata = function(evt) {
>   var bytes_received = evt.data.size();
>   if (useless_data_at_head_remaining > bytes_received) {
>     useless_data_at_head_remaining -= bytes_received;
>     return;
>   }
>
>   processUsefulData(evt.data.slice(uselesss_data_at_head_remaining));
> }
>
> If you meant the latter, I'm ok. I'd also call the latter "reading and
> discarding".

Yeah that seems about right.


> What use cases do you have in your mind? Your example in the thread was
> passing one to <video> but also accessing it manually using StreamReader. I
> think it's unknown in what timing and how much <video> consumes data from
> the Stream to the script and it's really hard make such coordination
> successful.
>
> Are you thinking of use case like mixing chat data and video contents in the
> same HTTP response body?

I haven't really thought about what I'd use it for, but I looked at
e.g. Dart and it seems to have a concept of broadcasted streams. Maybe
analyze the incoming bits in one function and in another you'd process
the incoming data and do something with it. Above all though it needs
to be clear what happens and for IO streams where you do not want to
keep all the data around (e.g. unlike the current Streams API) it's a
question that needs answering.


--
http://annevankesteren.nl/

Received on Friday, 17 May 2013 11:27:53 UTC