The WASI
class provides the WASI system call API and additional convenience methods for working with WASI-based applications. Each WASI
instance represents a distinct environment.
class
wasi.WASI
class WASI
- readonly wasiImport: Dict<any>
wasiImport
is an object that implements the WASI system call API. This object should be passed as thewasi_snapshot_preview1
import during the instantiation of aWebAssembly.Instance
. Return an import object that can be passed to
WebAssembly.instantiate()
if no other WASM imports are needed beyond those provided by WASI.If version
unstable
was passed into the constructor it will return:{ wasi_unstable: wasi.wasiImport }
If version
preview1
was passed into the constructor or no version was specified it will return:{ wasi_snapshot_preview1: wasi.wasiImport }
- instance: object): void;
Attempt to initialize
instance
as a WASI reactor by invoking its_initialize()
export, if it is present. Ifinstance
contains a_start()
export, then an exception is thrown.initialize()
requires thatinstance
exports aWebAssembly.Memory
namedmemory
. Ifinstance
does not have amemory
export an exception is thrown.If
initialize()
is called more than once, an exception is thrown. - instance: object): number;
Attempt to begin execution of
instance
as a WASI command by invoking its_start()
export. Ifinstance
does not contain a_start()
export, or ifinstance
contains an_initialize()
export, then an exception is thrown.start()
requires thatinstance
exports aWebAssembly.Memory
namedmemory
. Ifinstance
does not have amemory
export an exception is thrown.If
start()
is called more than once, an exception is thrown.