使用Promise.All创建地图
I have the following list = ["yellow", "blue", "red"]
我想在使用条目作为地图密钥时使用等待和PromiseAll创建一个地图,并且功能结果作为值。
例如:
async function concatStr(color): Promise<String> {
return color + "dosomthing"
}
and the map will be:
{
"yellow": "yellowdosomething",
"blue": "bluedosomething",
"red": "reddosomething"
}
我相信我需要使用产量,但不确定如何做
I have the following list = ["yellow", "blue", "red"]
I want to create a map, while with await and promiseAll while using the entries as the map key, and the function result as the value.
e.g:
async function concatStr(color): Promise<String> {
return color + "dosomthing"
}
and the map will be:
{
"yellow": "yellowdosomething",
"blue": "bluedosomething",
"red": "reddosomething"
}
I believe that I need to use yield , but not sure how to do it
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论