W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2013

Re: Overlap between StreamReader and FileReader

From: Aymeric Vitte <vitteaymeric@gmail.com>
Date: Fri, 04 Oct 2013 10:57:33 +0200
Message-ID: <524E82FD.9020905@gmail.com>
To: Takeshi Yoshino <tyoshino@google.com>
CC: Kenneth Russell <kbr@google.com>, Isaac Schlueter <i@izs.me>, Jonas Sicking <jonas@sicking.cc>, Austin William Wright <aaa@bzfx.net>, Domenic Denicola <domenic@domenicdenicola.com>, "public-webapps@w3.org" <public-webapps@w3.org>
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

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:27:03 UTC