Bluebird Map on HashMap/Obj

2019-08-04 13:23发布

问题:

I'm using the bluebird library to do asynchronous calls in javascript. I noticed there's a map function so I can apply a asynchronous function to each element in an array. However, I want to use this method on a object that has keys. Is there a way to do this?

回答1:

There are many way to convert an object to array like this :

Object.keys(yourObject).map(function(key){ return yourObject[key] })

You can use Promise.map too