Skip to main content

function

Function function 

Source
pub fn function<F>(
    context: &Context,
    name: &str,
    arity: u32,
    handler: F,
) -> Result<Value>
where F: FnMut(&Context, HostArgs) -> Result<Value> + 'static,
Expand description

Creates a direct native JS function with argument decoding and a panic boundary. An error throws a JavaScript exception; snapshots can return ordinary values synchronously. Use Context::promise only for genuinely asynchronous work.