feat(js) Support exception on WebAssembly::validate.

This commit is contained in:
Ivan Enderlin 2018-07-04 15:51:55 +02:00
parent fe25a9a268
commit c450fbf237
No known key found for this signature in database
GPG Key ID: 461F31FCE31F4AAD
2 changed files with 3 additions and 3 deletions

View File

@ -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

View File

@ -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#"