Merge pull request #1235 from fitzgen/some-little-things

A couple small improvements
This commit is contained in:
Alex Crichton 2019-02-11 06:39:09 -06:00 committed by GitHub
commit 311dafd366
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -612,7 +612,17 @@ impl<'a> Context<'a> {
memory = __exports.memory = {init_memory};
const response = fetch(module_or_path);
if (typeof WebAssembly.instantiateStreaming === 'function') {{
result = WebAssembly.instantiateStreaming(response, imports);
result = WebAssembly.instantiateStreaming(response, imports)
.catch(e => {{
console.warn(\"`WebAssembly.instantiateStreaming` failed. Assuming this is \
because your server does not serve wasm with \
`application/wasm` MIME type. Falling back to \
`WebAssembly.instantiate` which is slower. Original \
error:\\n\", e);
return response
.then(r => r.arrayBuffer())
.then(bytes => WebAssembly.instantiate(bytes, imports));
}});
}} else {{
result = response
.then(r => r.arrayBuffer())

View File

@ -4339,7 +4339,7 @@ impl From<String> for JsString {
impl<'a> From<&'a JsString> for String {
fn from(s: &'a JsString) -> Self {
s.obj.as_string().unwrap()
s.obj.as_string().unwrap_throw()
}
}