Skip to main content

compile_script_suspensible

Function compile_script_suspensible 

Source
pub fn compile_script_suspensible(
    program: &Program,
) -> Result<Function, SyntaxError>
Expand description

Compile a script whose top level is the body of an async function.

The body is an ordinary script in every other way — it still reports a completion value — but the value is wrapped in {value} and the function’s kind is Async, so running it answers a promise instead of a value. The wrapper is what keeps that promise from being adopted: await 1 completes with 1, and the reference resolves to {value: 1} rather than to 1 — the same shape std.evalScript(…, {async: true}) documents.