function a() {
console.log("a");
}
function b() {
console.log("b");
}
function c() {
console.log("c");
}
var fn = function (timer, cb=null) {
return new Promise(resolve => {
setTimeout(() => {
cb && cb()
resolve()
}, timer)
})
}
var step = function () {
Promise.resolve().then(() => {
return fn(5000, a)
}).then(() => {
return fn(3000, b)
}).then(() => {
return fn(6000)
}).then(() => {
return step()
})
}
step();