Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/JosiahParry/webr-js-rs

Rust bindings to the WebR javascript library
https://github.com/JosiahParry/webr-js-rs

Last synced: about 1 month ago
JSON representation

Rust bindings to the WebR javascript library

Awesome Lists containing this project

README

        

# webr-js-sys

Unofficial wasm-bindgen bindings for the [`WebR` JavaScript library](https://docs.r-wasm.org/) written in Rust.

This library crate only work ons wasm32-unknown-unknown target.

```rs
// create a new instance
let webr = crate::webr::WebR::new();

// initialize webR
let _ = webr.init().await;

// write to the console
let _ = webr.write_console("rnorm(100)".into());

// flush the console and read the output
let res = webr.flush_and_read().await;
res.iter().for_each(|x| {
web_sys::console::log_1(&JsValue::from_str(x));
});
```