#nodejs #javascript #repl

rusty_nodejs_repl

Run a Node.js Read Eval Print Loop from Rust

5 releases

0.2.1 Aug 27, 2024
0.2.0 Aug 25, 2024
0.1.2 Aug 24, 2024
0.1.1 Aug 22, 2024
0.1.0 Aug 22, 2024

#794 in Testing

Download history 304/week @ 2024-08-19 201/week @ 2024-08-26 24/week @ 2024-09-16 31/week @ 2024-09-30

220 downloads per month

MIT/Apache

15KB
279 lines

Rusty Node.js REPL 🦀 🌳 🌀

Documentation.

$ cargo add rusty_nodejs_repl

Usage

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.

What?

A way run arbitrary code through Node.js from Rust.

Why?

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.

Dependencies

~6–16MB
~228K SLoC