wasm: support wasm example on Safari
Этот коммит содержится в:
родитель
fbc2099ee3
коммит
4c29f0fdb6
1 изменённых файлов: 17 добавлений и 5 удалений
|
@ -13,11 +13,23 @@ function init() {
|
||||||
document.querySelector('#b').oninput = updateResult;
|
document.querySelector('#b').oninput = updateResult;
|
||||||
|
|
||||||
const go = new Go();
|
const go = new Go();
|
||||||
WebAssembly.instantiateStreaming(fetch(WASM_URL), go.importObject).then(function(obj) {
|
if ('instantiateStreaming' in WebAssembly) {
|
||||||
wasm = obj.instance;
|
WebAssembly.instantiateStreaming(fetch(WASM_URL), go.importObject).then(function(obj) {
|
||||||
go.run(wasm);
|
wasm = obj.instance;
|
||||||
updateResult();
|
go.run(wasm);
|
||||||
})
|
updateResult();
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
fetch(WASM_URL).then(resp =>
|
||||||
|
resp.arrayBuffer()
|
||||||
|
).then(bytes =>
|
||||||
|
WebAssembly.instantiate(bytes, go.importObject).then(function(obj) {
|
||||||
|
wasm = obj.instance;
|
||||||
|
go.run(wasm);
|
||||||
|
updateResult();
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче