Feature request: allow .each to accept objects
See original GitHub issueLibraries like Underscore and Lodash have implementations of each
which accept both arrays and objects as parameters, calling the provided function with (value, idx)
or (value, key)
depending on the input type.
This could be a useful extension to bluebird, saving having to do:
something().then(_.pairs).then(([k, v] => ...)
Or the equivalent with non-es6 functions.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How To Handle Feature Requests - The Ultimate Guide for ...
How to track and manage feature requests in an organized and systematic way, all leading to better product execution.
Read more >Allow Breadcrumb data to accept objects as values · Issue #88 ...
I think this could be a feature request opened on Sentry and if implemented, change the SDKs which is a coordinated thing now...
Read more >Feature Requests: Hot (424 ideas) – Horizon Worlds
If a similar idea already exists, you can support and comment on it. If it doesn't exist, you can post your idea so...
Read more >Feature requests - Please read before requesting something
If I have multiple objects (e.g. fields) selected going across the page, I would love to have an "Equal Horizontal" feature that would...
Read more >Product Feature Requests - How to Write and Submit Them
Describes the Feature Request process and provides tips on how to write a Feature Request for best results.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, you can - but also remember that this would happen part way through a Promise chain, so your suggestion would look like:
But with my suggestion, that would be
getMapFromAPI().each((data, key) => something(data))
Which is significantly more composable.
Given that Arrays are subclasses of objects (string keys mapped to values) it makes sense IMO to “genericise” this method up to objects rather than to have to create whole new lower-level strategies for writing this type of iteration code.
If you’re using lodash you can do
Instead of having us slowly implement every method of lodash in bluebird
(if some property values are promises, do
.props().then(_)...