5 stable releases
3.0.0 | Jun 28, 2024 |
---|---|
2.2.0 | Jan 31, 2024 |
2.1.0 | Sep 11, 2023 |
2.0.0 | Aug 17, 2023 |
1.0.0 | May 17, 2023 |
#1238 in WebAssembly
158 downloads per month
115KB
2.5K
SLoC
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
.
Dependencies
~8–12MB
~274K SLoC