HashMap/Obj上的蓝鸟地图 [英] Bluebird Map on HashMap/Obj

查看:57
本文介绍了HashMap/Obj上的蓝鸟地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用bluebird库在javascript中进行异步调用.我注意到这里有一个map函数,因此我可以将异步函数应用于数组中的每个元素.但是,我想在具有键的对象上使用此方法.有办法吗?

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?

推荐答案

有很多方法可以将对象转换为数组,如下所示:

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

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

您也可以使用Promise.map

You can use Promise.map too

这篇关于HashMap/Obj上的蓝鸟地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆