考虑到一系列承诺,在ES7中获得成果的惯用方法是什么?
这是我要做的:
async function getImports() { let imports = [System.import('./package1.js'),System.import('./package2.js')]; let promises = await* imports; let results = []; await promises.forEach(val => val.then(data => results.push(data))); //seems hacky console.log(results); // array of 2 resolved imports }