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 October 2017.

* Some parts of this feature may have varying levels of support.

**WebAssembly.compileStreaming()**함수는 스트림 된 원본 소스에서 직접 WebAssembly.Module을 컴파일합니다. 이 함수는 모듈을 인스턴스화하기 전에 컴파일해야하는 경우 유용합니다 (그렇지 않으면 WebAssembly.instantiateStreaming () 함수를 사용해야합니다).

Syntax

js
WebAssembly.compileStreaming(source);

Parameters

source

스트리밍 및 컴파일하려는 .wasm 모듈의 기본 소스를 나타내는 Response 객체 또는 약속을 수행합니다.

Return value

Promise는 컴파일 된 모듈로 표현된 WebAssembly.Module 객체로 반환됩니다.

Exceptions

Examples

다음 예제 (GitHub의 compile-streaming.html 데모 및 라이브보기)에서 기본 소스의 .wasm 모듈을 직접 스트리밍 한 다음 WebAssembly.Module 객체로 컴파일합니다. compileStreaming() 함수는 Response 객체에 대한 promise를 받으므로 직접 fetch() 호출을 전달할 수 있습니다.

js
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

브라우저 호환성

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
compileStreaming() static method
compileOptions parameter

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

See also