From 1bd0b2580b953a75f69d3f182f4b4518a7429e83 Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 20 Sep 2023 14:24:39 -0700 Subject: [PATCH] Added wasm binding --- src/lib.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 1e85639..d0737fc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,6 +17,24 @@ pub use crate::errors::DaisyError; 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)] pub fn do_string(