async function wait(func, ms) { return new Promise(resolve => { setTimeout(function () { resolve(func()); }, ms); }); }