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

Re: Is BlobBuilder needed?

From: ATSUSHI TAKAYAMA <taka.atsushi@googlemail.com>
Date: Thu, 27 Oct 2011 11:51:29 -0400
Message-ID: <CANmZ7J7DAT-C0ZC=8PSD1DP3A8XOH_fhz3psV=jXCyxKH6N1gg@mail.gmail.com>
To: Webapps WG <public-webapps@w3.org>, Jonas Sicking <jonas@sicking.cc>
Hi Jonas and all,

So converting Blob to ArrayBuffer is only supported through an
asynchronous API (FileReader's readAsArrayBuffer) except in Workers,
but the other way round is synchronous? I thought the direction of the
client side web was to make all API's that might involve disk access
asynchronous.

I like the API, though, except on this point.

A. TAKAYAMA

On Mon, Oct 24, 2011 at 6:52 PM, Jonas Sicking <jonas@sicking.cc> wrote:
> Hi everyone,
>
> It was pointed out to me on twitter that BlobBuilder can be replaced
> with simply making Blob constructable. I.e. the following code:
>
> var bb = new BlobBuilder();
> bb.append(blob1);
> bb.append(blob2);
> bb.append("some string");
> bb.append(myArrayBuffer);
> var b = bb.getBlob();
>
> would become
>
> b = new Blob([blob1, blob2, "some string", myArrayBuffer]);
>
> or look at it another way:
>
> var x = new BlobBuilder();
> becomes
> var x = [];
>
> x.append(y);
> becomes
> x.push(y);
>
> var b = x.getBlob();
> becomes
> var b = new Blob(x);
>
> So at worst there is a one-to-one mapping in code required to simply
> have |new Blob|. At best it requires much fewer lines if the page has
> several parts available at once.
>
> And we'd save a whole class since Blobs already exist.
>
> / Jonas
>
>
Received on Thursday, 27 October 2011 15:59:16 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:48 GMT