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

Re: Is BlobBuilder needed?

From: Jonas Sicking <jonas@sicking.cc>
Date: Mon, 24 Oct 2011 18:40:02 -0700
Message-ID: <CA+c2ei9srpuXOJcz+aT3tGQTMDkHSLrTci=vqDKD6YbTefG_Wg@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: Eric U <ericu@google.com>, Webapps WG <public-webapps@w3.org>
On Mon, Oct 24, 2011 at 4:46 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> On Mon, Oct 24, 2011 at 4:33 PM, Eric U <ericu@google.com> wrote:
>> The only things that this lacks that BlobBuilder has are the endings
>> parameter for '\n' conversion in text and the content type.  The
>> varargs constructor makes it awkward to pass in flags of any
>> sort...any thoughts on how to do that cleanly?
>
> Easy.  The destructuring stuff proposed for ES lets you easily say things like:
>
> function(blobparts..., keywordargs) {
>  // blobparts is an array of all but the last arg
>  // keywordargs is the last arg
> }
>
> or even:
>
> function(blobparts..., {contenttype, lineendings}) {
>  // blobparts is an array of all but the last arg
>  // contenttype and lineendings are pulled from the
>  // last arg, if it's an object with those properties
> }

The problem is that if the caller has an array, because this is a
constructor, this will get *very* awkward to do until ES6 is actually
implemented.

You can't simply do:

new Blob.apply(blobarray.concat("text/plain"));

I *think* this is what you'd have to do in a ES5 compliant engine:

new Blob.bind([null].concat(blobarray, "text/plain));

In ES3 I don't even think that there's a way to do it. Though that
might not matter assuming everyone gets .bind correctly implemented
before they implement |new Blob|.

I don't think the complexity is worth it for a dubious gain. I.e. it's
not entirely clear to me that the following:

new Blob(blob1, blob2, mybuffer, blob3, "somestring", "text/plain");

is significantly better than

new Blob([blob1, blob2, mybuffer, blob3, "somestring"], "text/plain");

/ Jonas
Received on Tuesday, 25 October 2011 01:41:03 GMT

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