// запускаем очередь со стартовым значением 1
Promise.resolve(1)
.then(r => {
return new Promise(resolve => {
setTimeout(() => {
return resolve(r+1);
},1000);
});
})
.then(r => {
return new Promise(resolve => {
setTimeout(() => {
return resolve(r+1);
},1000);
});
})
.then(r => {
console.log(r); // 3
})
async function run(start){
start = await new Promise(resolve => {
setTimeout(resolve,1000, start + 1);
});
start = await new Promise(resolve => {
setTimeout(resolve,1000, start + 1);
});
console.log(start);
}
run(1);