On Mon, Oct 6, 2014 at 8:19 PM, Rick Waldron <waldron.r...@gmail.com> wrote:

>
>
> On Mon, Oct 6, 2014 at 10:59 PM, Dmitry Soshnikov <
> dmitry.soshni...@gmail.com> wrote:
>
>> Hi,
>>
>> We're currently polyfilling `Array.from` in our codebase following the
>> latest draft [1]. And I was actually surprised by the `mapfn` being
>> involved into the algorithm.
>>
>
> Have you tried es6-shim?
>
>

Yeah, I'm aware of it, though, we have own versions for better performance,
since may skip some internal checks, etc.


>
>> I mean, from the performance perspective it's probably .. ok-ish.. but
>> from the API design perspective it feels like combining the actual
>> transformation of an iterable (or of an array-like) with the mapping, is
>> the "too much of responsibility" anti-pattern. Why not filter then as well?
>> (or, as one of the comments on a diff review: "I'm actually disappointed
>> it won't do my laundry as well :P").
>>
>> It probably should be just:
>>
>> ```
>> Array.from(...).map(mapfn);
>> ```
>>
>> Unless I'm missing something, and there was a special reason to include
>> the mapping.
>>
>
> Yes:
> https://github.com/rwaldron/tc39-notes/blob/c61f48cea5f2339a1ec65ca89827c8cff170779b/es6/2013-01/jan-30.md#revising-the-array-subclassing-kind-issue
> Any subclass of array will want to produce a list of its own "kind", but
> .map returns an Array. This thread is also a dup of:
> https://mail.mozilla.org/pipermail/es-discuss/2013-June/031500.html
>
>
I see. OK, thanks Rick, will re-read.

Dmitry
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to