let at = [
{
name: '第一',
time: 5000
},
{
name: '第二',
time: 2000
},
{
name: '第三',
time: 1000
}
];
let arr = at.map((val, index) => {
let time = null;
if (index === 0) {
time = 0;
} else {
time = at[index - 1].time
}
return {
name: val.name,
time: time
}
});
async function doMen(data) {
for (const i of data) {
const res = await someAPICall(i)
console.log('--->', res);
}
}
function someAPICall(param) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve("Resolved" + param.name)
}, param.time);
})
}
doMen(arr);
05-07
8631
02-26
843