| Crates.io | rusty_nodejs_repl |
| lib.rs | rusty_nodejs_repl |
| version | 0.2.1 |
| created_at | 2024-08-22 18:35:02.835101+00 |
| updated_at | 2024-08-27 03:54:22.372137+00 |
| description | Run a Node.js Read Eval Print Loop from Rust |
| homepage | |
| repository | https://github.com/cowlicks/rusty_nodejs_repl |
| max_upload_size | |
| id | 1348052 |
| size | 16,072 |
$ cargo add rusty_nodejs_repl
Put some JavaScript in a string and pass it to Repl::run. The function will return whatever was sent to stdout:
let mut repl = Config::build()?.start()?;
let result = repl.run("console.log('Hello, world!');").await?;
assert_eq!(result, b"Hello, world!\n");
For more in-depth usage see the test in the Rust Hypercore Replicator.
A way run arbitrary code through Node.js from Rust.
This is for testing. When working on Node.js related Rust projects it can allow you to co-locate JavaScript along side your Rust.
This crate came from implementing parts of the Hypercore JS ecosystem in Rust. Which requires testing Rust output against JavaScript.