On Mon, Aug 7, 2017 at 4:17 PM, Darien Valentine
<valentin...@gmail.com> wrote:
>
> > Where are you thinking of? [re: other methods that could take
overloaded/shorthand map/predicate args, but do not]
>
> These could also accept strings for property mapping in the same manner
you proposed, but do not currently:
>
> - `Array.from`
> - `Array.prototype.every`
> - ...

I think it comes down to what the majority use case is. For most of those
I've never used just a single property access. But I certainly have for
`map` and `filter`, I see your point there. It's not been anything like my
majority use case for those two, but definitely not rare.

> I think the spot where we might disagree is the assessment that
> "the string case is overwhelmingly the common one." This doesn’t
> sound quite right to me. That’s not been true in my experience...

:-) Your mileage may vary, but I'm surprised by that; surely you use maps
keyed by a property of the object they map to? The times I've wanted to
*generate* the key rather than just pluck it can be counted on one *finger*
(since `Object.create`; prior to that, I was prefixing names in index
objects to avoid `Object.prototype` collisions, back in the day). Whereas
wanting to use an existing property as the index key I've done hundreds of
times if not more. For instance, an app with a list of...well, almost
anything, where I want access both as a list (for iteration; showing the
list) and random access by ID (for showing details in response to a pick).

> > I'll create a proposal for what I want in a few days after more
> > feedback has come in.
>
> Would you consider the method you’ll be proposing to be "instead
> of" a reverse-of-object-entries type proposal, or is it
> orthogonal to that?

Ortogonal I think. Your `Object.fromEntries` works with an iterable of
`[key, value]` pairs (or, I'm guessing, a callback that can produce `[key,
value]` pairs). My `Object.from` works with an iterable of any kind of
object where the object itself is expected to be the value. I think trying
to shoehorn both in to one function would over-complicate it.

-- T.J. Crowder
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to