--- title: WebAssembly.compileStreaming() slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming ---
WebAssembly.compileStreaming()
함수는 스트림 된 원본 소스에서 직접 {{jsxref ( "WebAssembly.Module")}}을 컴파일합니다. 이 함수는 모듈을 인스턴스화하기 전에 컴파일해야하는 경우 유용합니다 (그렇지 않으면 {{jsxref ( "WebAssembly.instantiateStreaming ()")}} 함수를 사용해야합니다).
Promise<WebAssembly.Module> WebAssembly.compileStreaming(source);
Promise
는 컴파일 된 모듈로 표현된 WebAssembly.Module
객체로 반환됩니다.
bufferSource
가 typed array가 아니면 TypeError
가 발생합니다.WebAssembly.CompileError
와 함께 reject가 반환됩니다.다음 예제 (GitHub의 compile-streaming.html 데모 및 라이브보기)에서 기본 소스의 .wasm 모듈을 직접 스트리밍 한 다음 {{jsxref ( "WebAssembly.Module")}} 객체로 컴파일합니다. compileStreaming()
함수는 {{domxref ( "Response")}} 객체에 대한 promise를 받으므로 직접 {{domxref ( "WindowOrWorkerGlobalScope.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());
결과 모듈 인스턴스는 {{jsxref ( "WebAssembly.instantiate ()")}}를 사용하여 인스턴스화되고 내 보낸 함수가 호출됩니다.
Specification | Status | Comment |
---|---|---|
{{SpecName('WebAssembly Embedding', '#webassemblycompilestreaming', 'compileStreaming()')}} | {{Spec2('WebAssembly Embedding')}} | Initial draft definition. |
{{Compat("javascript.builtins.WebAssembly.compileStreaming")}}