Buckets:
| use mdxjs::{Options, compile}; | |
| use napi::bindgen_prelude::*; | |
| use napi_derive::napi; | |
| pub struct MdxCompileTask { | |
| pub input: String, | |
| pub option: Buffer, | |
| } | |
| impl Task for MdxCompileTask { | |
| type Output = String; | |
| type JsValue = String; | |
| fn compute(&mut self) -> napi::Result<Self::Output> { | |
| let options: Options = serde_json::from_slice(&self.option)?; | |
| compile(&self.input, &options) | |
| .map_err(|err| napi::Error::new(Status::GenericFailure, err.to_string())) | |
| } | |
| fn resolve(&mut self, _env: Env, output: Self::Output) -> napi::Result<Self::JsValue> { | |
| Ok(output) | |
| } | |
| } | |
| pub fn mdx_compile( | |
| value: String, | |
| option: Buffer, | |
| signal: Option<AbortSignal>, | |
| ) -> napi::Result<AsyncTask<MdxCompileTask>> { | |
| let task = MdxCompileTask { | |
| input: value, | |
| option, | |
| }; | |
| Ok(AsyncTask::with_optional_signal(task, signal)) | |
| } | |
| pub fn mdx_compile_sync(value: String, option: Buffer) -> napi::Result<String> { | |
| let option: Options = serde_json::from_slice(&option)?; | |
| compile(value.as_str(), &option) | |
| .map_err(|err| napi::Error::new(Status::GenericFailure, format!("{err:?}"))) | |
| } | |
Xet Storage Details
- Size:
- 1.18 kB
- Xet hash:
- 904d46fbf6f8614952d7e4c8a57aa75310d6f69ae170c8b5eb87940eacd5acf5
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.