mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-24 18:43:33 +03:00
feat(js) Support exception on WebAssembly::validate
.
This commit is contained in:
parent
fe25a9a268
commit
c450fbf237
@ -1148,8 +1148,8 @@ extern "C" {
|
||||
/// form a valid wasm module (`true`) or not (`false`).
|
||||
///
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/validate
|
||||
#[wasm_bindgen(static_method_of = WebAssembly)]
|
||||
pub fn validate(bufferSource: JsValue) -> bool;
|
||||
#[wasm_bindgen(static_method_of = WebAssembly, catch)]
|
||||
pub fn validate(bufferSource: JsValue) -> Result<bool, JsValue>;
|
||||
}
|
||||
|
||||
// JsString
|
||||
|
@ -15,7 +15,7 @@ fn validate() {
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn validate_wasm(wasm: JsValue) -> bool {
|
||||
WebAssembly::validate(wasm)
|
||||
WebAssembly::validate(wasm).unwrap_or(false)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
|
Loading…
Reference in New Issue
Block a user