javy

Crates.iojavy
lib.rsjavy
version3.0.1
sourcesrc
created_at2023-05-17 17:26:53.159663
updated_at2024-09-18 16:59:17.878813
descriptionConfigurable JavaScript runtime for WebAssembly
homepagehttps://github.com/bytecodealliance/javy/tree/main/crates/javy
repositoryhttps://github.com/bytecodealliance/javy/tree/main/crates/javy
max_upload_size
id867111
size120,501
javy-publish (github:bytecodealliance:javy-publish)

documentation

README

Javy

A configurable JavaScript runtime for WebAssembly

Documentation Status crates.io status

Uses QuickJS through the rquickjs crate to evalulate JavaScript source code or QuickJS bytecode.

Refer to the crate level documentation to learn more.

Example usage:

use anyhow::anyhow;
use javy::{Runtime, from_js_error};
let runtime = Runtime::default();
let context = runtime.context();

context.with(|cx| {
    let globals = this.globals();
    globals.set(
        "print_hello",
        Function::new(
            this.clone(),
            MutFn::new(move |_, _| {
                println!("Hello, world!");
            }),
        )?,
    )?;
 });

context.with(|cx| {
    cx.eval_with_options(Default::default(), "print_hello();")
         .map_err(|e| from_js_error(cx.clone(), e))
         .map(|_| ())
});

Publishing to crates.io

To publish this crate to crates.io, run ./publish.sh.

Commit count: 0

cargo fmt