WebAssembly.compile()
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since â¨2017ë 10ìâ©.
* Some parts of this feature may have varying levels of support.
**WebAssembly.compile()**í¨ìë WebAssembly ë°ì´ë리 ì½ëìì WebAssembly.Moduleì ì»´íì¼í©ëë¤. ì´ í¨ìë 모ëì ì¸ì¤í´ì¤íí기 ì ì ì»´íì¼í´ì¼íë ê²½ì°ì ì ì©í©ëë¤. ê·¸ë ì§ ìì¼ë©´ WebAssembly.instantiate () í¨ì를 ì¬ì©í´ì¼í©ëë¤.
Syntax
WebAssembly.compile(bufferSource);
Parameters
- bufferSource
-
ì»´íì¼ í .wasm 모ëì ì´ì§ ì½ëê° ë¤ì´ìë typed array ëë ArrayBufferì ëë¤.
Return value
Promiseë ì»´íì¼ ë 모ëë¡ ííë WebAssembly.Module ê°ì²´ë¡ ë°íë©ëë¤.
Exceptions
bufferSourceê° typed arrayê° ìëë©´TypeErrorê° ë°ìí©ëë¤.- ì»´íì¼ì ì¤í¨íë©´ promiseë
WebAssembly.CompileErrorì í¨ê» rejectê° ë°íë©ëë¤.
Examples
ë¤ìì compile() í¨ì를 ì¬ì©íì¬ simple.wasm ë°ì´í¸ ì½ë를 ì»´íì¼ íê³ postMessage()를 ì¬ì©íì¬ workerì ë³´ë´ë ìì ì
ëë¤.
var worker = new Worker("wasm_worker.js");
fetch("simple.wasm")
.then((response) => response.arrayBuffer())
.then((bytes) => WebAssembly.compile(bytes))
.then((mod) => worker.postMessage(mod));
ì°¸ê³ :
ëë¶ë¶ì ê²½ì°ì WebAssembly.compileStreaming()를 ì¬ì©íë ê²ì´ ì¢ìµëë¤. ì´ë compile()ë³´ë¤ í¨ì¨ì ì´ê¸° ë문ì
ëë¤.
ëª ì¸ì
| Specification |
|---|
| WebAssembly JavaScript Interface > # dom-webassembly-compile > |