WebAssembly.compileStreaming()
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. Itโs been available across browsers since โจ2021๋ 9์โฉ.
* Some parts of this feature may have varying levels of support.
**WebAssembly.compileStreaming()
**ํจ์๋ ์คํธ๋ฆผ ๋ ์๋ณธ ์์ค์์ ์ง์ WebAssembly.Module
์ ์ปดํ์ผํฉ๋๋ค. ์ด ํจ์๋ ๋ชจ๋์ ์ธ์คํด์คํํ๊ธฐ ์ ์ ์ปดํ์ผํด์ผํ๋ ๊ฒฝ์ฐ ์ ์ฉํฉ๋๋ค (๊ทธ๋ ์ง ์์ผ๋ฉด WebAssembly.instantiateStreaming ()
ํจ์๋ฅผ ์ฌ์ฉํด์ผํฉ๋๋ค).
Syntax
WebAssembly.compileStreaming(source);
Parameters
Return value
Promise
๋ ์ปดํ์ผ ๋ ๋ชจ๋๋ก ํํ๋ WebAssembly.Module
๊ฐ์ฒด๋ก ๋ฐํ๋ฉ๋๋ค.
Exceptions
bufferSource
๊ฐ typed array๊ฐ ์๋๋ฉดTypeError
๊ฐ ๋ฐ์ํฉ๋๋ค.- ์ปดํ์ผ์ ์คํจํ๋ฉด promise๋
WebAssembly.CompileError
์ ํจ๊ป reject๊ฐ ๋ฐํ๋ฉ๋๋ค.
Examples
๋ค์ ์์ (GitHub์ compile-streaming.html ๋ฐ๋ชจ ๋ฐ ๋ผ์ด๋ธ๋ณด๊ธฐ)์์ ๊ธฐ๋ณธ ์์ค์ .wasm ๋ชจ๋์ ์ง์ ์คํธ๋ฆฌ๋ฐ ํ ๋ค์ WebAssembly.Module
๊ฐ์ฒด๋ก ์ปดํ์ผํฉ๋๋ค. compileStreaming()
ํจ์๋ Response
๊ฐ์ฒด์ ๋ํ promise๋ฅผ ๋ฐ์ผ๋ฏ๋ก ์ง์ fetch()
ํธ์ถ์ ์ ๋ฌํ ์ ์์ต๋๋ค.
var importObject = { imports: { imported_func: (arg) => console.log(arg) } };
WebAssembly.compileStreaming(fetch("simple.wasm"))
.then((module) => WebAssembly.instantiate(module, importObject))
.then((instance) => instance.exports.exported_func());
๊ฒฐ๊ณผ ๋ชจ๋ ์ธ์คํด์ค๋ WebAssembly.instantiate ()
๋ฅผ ์ฌ์ฉํ์ฌ ์ธ์คํด์คํ๋๊ณ ๋ด ๋ณด๋ธ ํจ์๊ฐ ํธ์ถ๋ฉ๋๋ค.
๋ช ์ธ์
Specification |
---|
WebAssembly Web API # dom-webassembly-compilestreaming |
๋ธ๋ผ์ฐ์ ํธํ์ฑ
Loadingโฆ