Dmitry Soshnikov
2014-10-07 02:59:32 UTC
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.
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.
Dmitry
[1] https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141006/68804c36/attachment.html>
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.
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.
Dmitry
[1] https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141006/68804c36/attachment.html>