3 ms·
It iterates over all key/value pairs. For each value, if it is a promise it waits for it and replaces it with the result, while non-promises are left as-is. Thi
by thedufer 7y ago
It iterates over all key/value pairs. For each value, if it is a promise it waits for it and replaces it with the result, while non-promises are left as-is. This is a fairly common function to have in promise libraries.
- korla 7y agoThat was my point. It’s not obvious to the reader that this is better since it’s a non-standard way of resolving promises. But it looks neat. I’ve never seen it, what library do you have experience with that does it this way?
- thedufer 7y agoI've been out of the JavaScript world for years now, but I last used Bluebird which has Promise.props[1] with this behavior. [1] http://bluebirdjs.com/docs/api/promise.props.html http://bluebirdjs.com/docs/api/promise.props.html