[][src]Crate scriptit

scriptit is a simple way to run JavaScript code in Rust

scriptit will run your JS differently depending on your platform:

  • Run in a V8 interpreter for "native" targets
  • Run in the WASM host interpreter for "wasm32" targets

Example

use scriptit::{ core::value::ScriptValue, ScriptingEnvironment };

let mut s_env = ScriptingEnvironment::new();

let src = "
    const greeter = 'JS';
    const greeted = 'Rust';
    `Hello ${greeted}! (from ${greeter}...)`
";
let res = s_env.eval(src).unwrap();

assert_eq!(res, ScriptValue::String("Hello Rust! (from JS...)".to_string()));

Modules

core

Core constructs available on all platforms

Structs

ScriptingEnvironment

A V8 scripting environment. This API also exists on WASM but JS will execute insecurely there.