Skip to main content
WASI - wasi - Node documentation
class WASI

Usage in Deno

import { WASI } from "node:wasi";
<div class="alert alert-warning"><div><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" fill="none" /> <path d="M12 9v4" /> <path d="M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0z" /> <path d="M12 16h.01" /> </svg> Deno compatibility</div><div><p> This symbol is a non-functional stub.</p> </div></div>

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.

Constructors

new
WASI(options?: WASIOptions)

Properties

readonly
wasiImport: Dict<any>

wasiImport is an object that implements the WASI system call API. This object should be passed as the wasi_snapshot_preview1 import during the instantiation of a WebAssembly.Instance.

Methods

getImportObject(): object

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 }
initialize(instance: object): void

Attempt to initialize instance as a WASI reactor by invoking its _initialize() export, if it is present. If instance contains a _start() export, then an exception is thrown.

initialize() requires that instance exports a WebAssembly.Memory named memory. If instance does not have a memory export an exception is thrown.

If initialize() is called more than once, an exception is thrown.

start(instance: object): number

Attempt to begin execution of instance as a WASI command by invoking its _start() export. If instance does not contain a _start() export, or if instance contains an _initialize() export, then an exception is thrown.

start() requires that instance exports a WebAssembly.Memory named memory. If instance does not have a memory export an exception is thrown.

If start() is called more than once, an exception is thrown.