Skip to main content

parse_suspensible_script

Function parse_suspensible_script 

Source
pub fn parse_suspensible_script(src: &str) -> Result<Program>
Expand description

Parse src as a Script whose top level is the body of an async function.

This is the reference’s JS_EVAL_FLAG_ASYNC, which std.evalScript sets from {async: true}. The flag buys exactly one thing: top-level await becomes an operator, because the program’s own function is an async one. It does not make the top level a function — return stays an error and new.target stays unavailable — so the compiled body still reports its completion value the way a script does, wrapped in {value} so that a promise is not adopted on the way out.