Bluebird Map on HashMap/Obj

2019-08-04 13:43发布

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条回答
神经病院院长
2楼-- · 2019-08-04 14:13

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

查看更多
登录 后发表回答