Update idioms of a few examples

* Use `TypedArray::view` now that it exists.
* Don't hack around `instantiateStreaming`
This commit is contained in:
Alex Crichton
2019-02-19 13:27:30 -08:00
parent 5b0cfd7cea
commit b8f080d523
3 changed files with 12 additions and 27 deletions

View File

@ -3,19 +3,6 @@
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
</head>
<body>
<script>
// The `--no-modules`-generated JS from `wasm-bindgen` attempts to use
// `WebAssembly.instantiateStreaming` to instantiate the wasm module,
// but this doesn't work with `file://` urls. This example is frequently
// viewed by simply opening `index.html` in a browser (with a `file://`
// url), so it would fail if we were to call this function!
//
// Work around this for now by deleting the function to ensure that the
// `no_modules.js` script doesn't have access to it. You won't need this
// hack when deploying over HTTP.
delete WebAssembly.instantiateStreaming;
</script>
<!-- this is the JS generated by the `wasm-bindgen` CLI tool -->
<script src='./pkg/no_modules.js'></script>