-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Values map #27
Comments
Does this work for you? const values = require('object-loops/values')
people = {
john: "John Lennon",
ringo: "Ringo Starr"
}
<div>
{values(people).map(name => `Mr. ${name}`)}
</div> |
Yeah, that's what I've been doing, or rather: values(map(people, (name, key) => /*...*/)) Would be nice to have it be done in one step in an optimized, though :) |
What about a lazy version of chain? const lazy = require('object-loops/lazy')
people = {
john: "John Lennon",
ringo: "Ringo Starr"
}
{lazy(people).values().map(name => Mr. ${name}`).toJSON()} |
We could implement this by keeping track of all methods called then compute them all in one |
I would like to avoid a creating a "values map" in object loops, bc then it would only make sense to create them all ("values forEach", "values reduce", etc). Let me know if lazy works for you I am happy to implement it this weekend if you are (or you can PR it 🙂) |
Oh hey. :) So I think I gave a bad use case here, and bad naming. What I'm looking for is a way to do this: people = {
john: "John Lennon",
ringo: "Ringo Starr"
}
<div>
{listMap(people, (name, id) => <li id={id}>Mr. ${name}</li>)}
</div> So in this case,
That said, the only functions it makes sense on are:
|
It'd be nice to have a version of
.map
that will always return an array instead of an object. Very useful for JSX.I can send you a PR, but I don't know what to name this function!
The text was updated successfully, but these errors were encountered: