Crate javy

source ·
Expand description

Configurable JavaScript runtime for WebAssembly.

Example usage:

let runtime = Runtime::default();
let context = runtime.context();
context
    .global_object()
    .unwrap()
    .set_property(
        "print",
        context
            .wrap_callback(move |_ctx, _this, args| {
                let str = args
                    .first()
                    .ok_or(anyhow!("Need to pass an argument"))?
                    .to_string();
                println!("{str}");
                Ok(JSValue::Undefined)
            })
            .unwrap(),
    )
    .unwrap();
context.eval_global("hello.js", "print('hello!');").unwrap();

§Core concepts

  • Runtime - The entrypoint for using the JavaScript runtime. Use a Config to configure behavior.

§Features

Re-exports§

Modules§

Structs§