(source_text: String, options: JsValue)
| 92 | |
| 93 | #[wasm_bindgen] |
| 94 | pub fn format(source_text: String, options: JsValue) -> Result<String, serde_wasm_bindgen::Error> { |
| 95 | let options: FormatOptions = match serde_wasm_bindgen::from_value(options) { |
| 96 | Ok(opts) => opts, |
| 97 | Err(_e) => { |
| 98 | #[cfg(feature = "console_error_panic_hook")] |
| 99 | web_sys::console::warn_1(&format!("Failed to parse format options: {}. Using defaults.", _e).into()); |
| 100 | FormatOptions::default() |
| 101 | } |
| 102 | }; |
| 103 | format_with_options(&source_text, options).map_err(serde_wasm_bindgen::Error::new) |
| 104 | } |
| 105 | |
| 106 | fn format_with_options(source_text: &str, options: FormatOptions) -> Result<String, String> { |
| 107 | let allocator = Bump::default(); |
no test coverage detected