亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在新的Promise()構造函數中使用async / await是一種反模式嗎?

在新的Promise()構造函數中使用async / await是一種反模式嗎?

紅顏莎娜 2019-08-19 16:16:39
在新的Promise()構造函數中使用async / await是一種反模式嗎?我正在使用該async.eachLimit功能一次控制最大操作數。const { eachLimit } = require("async");function myFunction() {  return new Promise(async (resolve, reject) => {    eachLimit((await getAsyncArray), 500, (item, callback) => {      // do other things that use native promises.    }, (error) => {      if (error) return reject(error);      // resolve here passing the next value.    });  });}如您所見,我無法將該myFunction函數聲明為異步,因為我無法訪問eachLimit函數的第二個回調內的值。
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 681 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號