Re: Overlap between StreamReader and FileReader

I am still not very familiar with promises, but if I take your 
preceeding example:

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(
   ...
);


shoud'nt it be more something like:

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

or

var sourceStream = xhr.response;
var encryptionPromise = crypto.subtle.encrypt(aesAlgorithmEncrypt, aesKey);
var hashPromise = crypto.subtle.digest(hash);
var resultStream = sourceStream.pipe([encryptionPromise,hashPromise]);
var fileWritingPromise = fileWriter.write(resultStream);
Promise.all(fileWritingPromise, resultStream).then(
   ...
);

Regards

Aymeric

Le 03/10/2013 10:27, Takeshi Yoshino a écrit :
> Formatted and published my latest proposal at github after 
> incorporating Aymeric's multi-dest idea.
>
> http://htmlpreview.github.io/?https://github.com/tyoshino/stream/blob/master/streams.html
>
>
> On Sat, Sep 28, 2013 at 11:45 AM, Kenneth Russell <kbr@google.com 
> <mailto:kbr@google.com>> wrote:
>
>     This looks nice. It looks like it should already handle the flow
>     control issues mentioned earlier in the thread, simply by
>     performing the read on demand, though reporting the result
>     asynchronously.
>
>
> Thanks, Kenneth for reviewing.

-- 
Peersm : http://www.peersm.com
node-Tor : https://www.github.com/Ayms/node-Tor
GitHub : https://www.github.com/Ayms

Received on Friday, 4 October 2013 08:58:12 UTC