function timer(ms) {
return new Promise(resolve => {
setTimeout(() => {
resolve()
}, ms)
})
}
async function start(data) {
for (let i in data) {
await timer(500)
let res = await printing(data[i])
window.tablo.innerHTML += res
}
}
function printing (screen) {
return new Promise (function (resolve, reject) {
if (screen['next'] == 1) {
resolve(screen['str']);
} else {
reject('дальше строчек нет');
}
});
}
start(screen)