| Crates.io | easyjsr |
| lib.rs | easyjsr |
| version | 0.4.5 |
| created_at | 2025-09-04 21:35:07.236746+00 |
| updated_at | 2025-10-05 19:33:32.912914+00 |
| description | easyjs internal JS runtime |
| homepage | https://jordanmcastro.com/easyjs |
| repository | https://github.com/jordan-castro/easyjs |
| max_upload_size | |
| id | 1824828 |
| size | 2,723,232 |
Default runtime for easyjs. Rust wrapper of ejr.
To use with easyjs you can set the runtime to easyjsr. It is also the default runtime.
easyjs repl --runtime easyjsr
> import 'std'
> @print('Hello World')
This is a really easy to use runtime for embedding in rust projects. Important thing to note is that it does not currently support MSVC builds. Only GNU/Clang. So if using windows make sure to install the correct build system.
rustup target add x86_64-pc-windows-gnu
# And build with
cargo build --target x86_64-pc-windows-gnu
let result = ejr.eval("1 + 1");
println!("{}", ejr.val_to_string(result)); // 2
let script = r##"
function say_hello_to(name) {
console.log('Hello', name);
}
"##;
let result = ejr.call("say_hello_to", vec!["Jordan"]); // Hello Jordan
fn ___print(msg: String) {
println!("{msg}");
}
ejr.register_callback("___print", ___print);
// Lambdas
ejr.register_callback("___log", |msg: String| {
println!("{msg}");
});
This is mostly for libraries, you usually won't use this in an app.
compile_js_code(code);
// Or as a module
compile_js_code_as_module(code);
The use case of another JS runtime is specifically to be a high level wrapper for easy FFI use in:
All projects that use easyjs as scripting.