Crate rusty_nodejs_repl

Crate rusty_nodejs_repl 

Source
Expand description

This crate lets you run arbitrary code in a Node.js REPL from Rust. Use Config to setup the REPL and use Repl to interact with it.

let mut repl: Repl = Config::build()?.start().await?;
let result = repl.run("console.log('Hello, world!');").await?;
assert_eq!(result, b"Hello, world!\n");
repl.stop().await?;

The REPL is run in it’s own tempfile::TempDir. So any files created alongside it will be cleaned up on exit.

Modules§

pipe
JavaScript & Rust socket communication

Macros§

wait
sleep().await for the given # of millis. Defaults to 100ms. Useful for async testing .

Structs§

Config
Configurating for Repl. Usually you will want to setup the REPL context by importing some modules and doing some setup. Then maybe, run some teardown code after the REPL closes. Do this by giving JavaScript strings to Config::imports, Config::before, and Config::after fields.
ConfigBuilder
Builder for Config.
Repl
Interface to the Node.js REPL. Send code with Repl::run, stop it with Repl::stop.

Enums§

ConfigBuilderError
Error type for ConfigBuilder
Error

Type Aliases§

Result
Alias of std::error::Error to use our own Error