Added wasm binding

pull/6/head
Mark 2023-09-20 14:24:39 -07:00
parent dbde7cb6f4
commit 1bd0b2580b
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
1 changed files with 18 additions and 0 deletions

View File

@ -17,6 +17,24 @@ pub use crate::errors::DaisyError;
pub use crate::evaluate::evaluate; pub use crate::evaluate::evaluate;
cfg_if::cfg_if! {
if #[cfg(target_arch = "wasm32")] {
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn dostr(x: String) -> String{
let mut context = Context::new();
let x = x.trim().to_string();
let r = do_string(&mut context, &x);
match r {
Ok(t) | Err(t) => {
return t.write();
}
}
}
}
}
#[inline(always)] #[inline(always)]
pub fn do_string( pub fn do_string(