I ultimately used map.values() within a for await loop.
Here's a contrived example that showcases await working within a loop:
async function delay(ms) { console.log(`Waiting ${ms} milliseconds . . .`); return new Promise((resolve)=>{ setTimeout(resolve, ms); }); } async function main() { let map = new Map([[1,"A"],[2,"B"],[3,"C"]]); for await (const value of map.values()) { await delay(2000); console.log(value); } } main();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.