Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Perhaps just mimic Array.from()? #4

Closed
getify opened this issue Oct 7, 2019 · 3 comments
Closed

Perhaps just mimic Array.from()? #4

getify opened this issue Oct 7, 2019 · 3 comments

Comments

@getify
Copy link

getify commented Oct 7, 2019

Two options... could Object.fromEntries() just add an optional second param function that's called for each entry?

Or just add Object.from() which shallow-iterates a whole object (like Object.assign() does) but then has the optional second param function?

@ljharb
Copy link
Member

ljharb commented Oct 7, 2019

See tc39/proposal-object-from-entries#13 - it's not a clear-cut choice for what the second argument should be.

For the latter, would Object.from just be function (o, fn) { return Object.fromEntries(Object.entries(o).map(fn)); }?

@getify
Copy link
Author

getify commented Oct 7, 2019

For the latter, would Object.from just be...

Yep, that makes sense to me.

@decompil3d
Copy link
Member

Agreed. Furthermore, this sort of arcane mechanism is not nearly as clear as just having a direct way to call a map operation over an iterated collection.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants