silverwolf-x's picture
download
raw
890 Bytes
use js_sys::JsString;
use wasm_bindgen::prelude::*;
use wasm_bindgen_futures::future_to_promise;
#[wasm_bindgen(js_name = "mdxCompileSync")]
pub fn mdx_compile_sync(value: JsString, opts: JsValue) -> Result<JsValue, JsValue> {
let value: String = value.into();
let option: mdxjs::Options = serde_wasm_bindgen::from_value(opts)?;
mdxjs::compile(value.as_str(), &option)
.map(|v| serde_wasm_bindgen::to_value(&v).expect("Should able to convert to JsValue"))
.map_err(|v| {
serde_wasm_bindgen::to_value(&v.to_string()).expect("Should able to convert to JsValue")
})
}
#[wasm_bindgen(js_name = "mdxCompile")]
pub fn mdx_compile(value: JsString, opts: JsValue) -> js_sys::Promise {
// TODO: This'll be properly scheduled once wasm have standard backed thread
// support.
future_to_promise(async { mdx_compile_sync(value, opts) })
}

Xet Storage Details

Size:
890 Bytes
·
Xet hash:
d81214c66b23c69619dc1b9c4df41f2e26a13c347e86e5b01e5626560fe0bbda

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.