-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(js): remove double wrap (#1138)
- Loading branch information
1 parent
8a92bb7
commit c765a53
Showing
6 changed files
with
197 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use rattler_conda_types::ParseStrictness; | ||
use serde::Deserialize; | ||
use wasm_bindgen::prelude::wasm_bindgen; | ||
|
||
#[wasm_bindgen(typescript_custom_section)] | ||
const PARSE_STRICTNESS_TS: &'static str = r#" | ||
/** | ||
* Defines how strict a parser should be when parsing an object from a string. | ||
* | ||
* @public | ||
*/ | ||
export type ParseStrictness = "strict" | "lenient"; | ||
"#; | ||
|
||
#[wasm_bindgen] | ||
extern "C" { | ||
#[wasm_bindgen(js_name = "ParseStrictness", typescript_type = "ParseStrictness")] | ||
pub type JsParseStrictness; | ||
} | ||
|
||
impl TryFrom<JsParseStrictness> for ParseStrictness { | ||
type Error = serde_wasm_bindgen::Error; | ||
|
||
fn try_from(value: JsParseStrictness) -> Result<Self, Self::Error> { | ||
#[derive(Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub enum EnumNames { | ||
Strict, | ||
Lenient, | ||
} | ||
|
||
match serde_wasm_bindgen::from_value(value.obj)? { | ||
EnumNames::Strict => Ok(ParseStrictness::Strict), | ||
EnumNames::Lenient => Ok(ParseStrictness::Lenient), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.