Bluebird Map on HashMap/Obj

若如初见. 提交于 2019-12-24 11:44:29

问题


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



来源:https://stackoverflow.com/questions/32193946/bluebird-map-on-hashmap-obj

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!