Re: Overlap between StreamReader and FileReader

On Thu, Sep 26, 2013 at 6:36 PM, Aymeric Vitte <vitteaymeric@gmail.com>wrote:

> Looks good, comments/questions :
>
> - what's the use of readEncoding?
>

Overriding charset specified in .type for read op. It's weird but we can
ask an app to overwrite .type instead.


>
> - StreamReadType: add MediaStream? (and others if existing)
>

Maybe, if there's clear rule to convert binary stream + MIME type into
MediaStream object.


>
> - would it be possible to pipe from StreamReadType to other StreamReadType?
>

pipe() tells the receiver with which value of StreamReadType the pipe() was
called. Receiver APIs may be designed to accept either mode or both modes.


>
> - would it be possible to pipe from a source to different targets (my
> example of encrypt/hash at the same time)?
>

I missed it. Your mirroring method (making pipe accept multiple Stream)
looks good.

The problem is what to do when one of destinations is write blocked. Maybe
we want to read data from the source as the fastest consumer consumes and
save read data for slowest one. When should we fulfill the promise?
Completion of read from the source, completion of write to all
destinations, etc.


>
> - what is the link between the API and the Stream (responseType='stream')?
> How do you handle this for APIs where responseType does not really apply
> (mspack, crypto...)
>

- make APIs to return a Stream for read (write) like
XHR.responseType='stream'
- make APIs to accept a Stream for read (write)

Either should work as we have pipe().

E.g.

var sourceStream = xhr.response;
var resultStream = new Stream();
var fileWritingPromise = fileWriter.write(resultStream);
var encryptionPromise = crypto.subtle.encrypt(aesAlgorithmEncrypt, aesKey,
sourceStream, resultStream);
Promise.all(fileWritingPromise, encryptionPromise).then(
  ...
);

----

I also found a point needs clarification

- pipe() does eof or not. I think we don't want automatic eof.

Received on Thursday, 26 September 2013 14:45:56 UTC