Array.prototype.toObjectByProperty( element=>element.property )
T.J. Crowder
tj.crowder at farsightsoftware.com
Thu Aug 10 09:14:30 UTC 2017
On Thu, Aug 10, 2017 at 9:49 AM, Naveen Chawla <naveen.chwl at gmail.com>
wrote:
>
> I think a property value callback is needed for completeness (not
> easy to achieve the same functionality without it.
In my view, a Swiss Army knife is not a good API function. (These are
always, of course, judgement calls.) The `[key, value]` case can be
addressed with Darien's `Object.fromEntries`. I've literally never needed
that, but if one does, having something specific for it which fits into the
`[key, value]` ecosystem makes sense to me. That's why I've said several
times now that my suggestion and Darien's draft proposal are complementary,
not conflicting/competing. In fact, it may be useful to combine them (but
not the functions they define).
Separately, I wonder how a second callback (in the case where it's a
callback) compares in terms of performance and memory churn with returning
`[key, value]` arrays.
> Keying by a string property name should, in my view, be a separate
> function
I don't see the need. If it does exactly the same thing, just using a
string directly rather than calling a function, then like `String#replace`
I'm happy for it to handle that. Again, though, these are always judgement
calls.
-- T.J. Crowder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170810/27550d17/attachment.html>
More information about the es-discuss
mailing list