quickjspp-rs

Crates.io docs.rs

This is a fork of quickjs-rs but replaces the binding to the original quickjs by Fabrice Bellard with its fork quickjspp by Andrew Fedoniouk, which is MSVC compatible/compileable.

QuickJS is a new, small Javascript engine by Fabrice Bellard and Charlie Gordon. It is fast and supports the full ES2020 specification.

QuickJSpp is a fork of Quickjs By Andrew Fedoniouk (a.k.a. c-smile).

This crate allows you to easily run and integrate with Javascript code from Rust.

Quickstart

toml [dependencies] quickjspp = "0.4.1"

```rust use quickjspp::{Context, JsValue};

let context = Context::new().unwrap();

// Eval.

let value = context.eval("1 + 2").unwrap(); assert_eq!(value, JsValue::Int(3));

let value = context.evalas::(" var x = 100 + 250; x.toString() ").unwrap(); asserteq!(&value, "350");

// Callbacks.

context.add_callback("myCallback", |a: i32, b: i32| a + b).unwrap();

context.eval(r#" // x will equal 30 var x = myCallback(10, 20); "#).unwrap(); ```

Optional Features

The crate supports the following features:

Installation

By default, quickjs is bundled with the libquickjs-sys crate and automatically compiled, assuming you have the appropriate dependencies.

Windows Support

quickjspp-rs can be used under target x86_64-pc-windows-msvc,

System installation

To use the system installation, without the bundled feature, first install the required dependencies, and then compile and install quickjspp.

You then need to disable the bundled feature in the libquickjs-sys crate to force using the system version.