I want to eval() some lines of code inside of async function. While the following code is ok,
async function foo() { await foo1(); await foo2(); }
Ended up using Ermir`s answer:
let ctxScript = '(async () => {await foo1();await foo2();is_script_ended = true; })();'; async function foo() { // a lot of code is_script_ended = false; eval( ctxScript ); while(!is_script_ended){ await sleep(1000); } // a lot of code }