new WASI([options])


  • options <Object>

    • args <Array> WebAssembly 应用将视为命令行参数的字符串数组。第一个参数是 WASI 命令本身的虚拟路径。默认值:[]

      ¥args <Array> An array of strings that the WebAssembly application will see as command-line arguments. The first argument is the virtual path to the WASI command itself. Default: [].

    • env <Object> 类似于 process.env 的对象,WebAssembly 应用将其视为其环境。默认值:{}

      ¥env <Object> An object similar to process.env that the WebAssembly application will see as its environment. Default: {}.

    • preopens <Object> 该对象表示 WebAssembly 应用的本地目录结构。preopens 的字符串键被视为文件系统中的目录。preopens 中对应的值是宿主机上这些目录的真实路径。

      ¥preopens <Object> This object represents the WebAssembly application's local directory structure. The string keys of preopens are treated as directories within the file system. The corresponding values in preopens are the real paths to those directories on the host machine.

    • returnOnExit <boolean> 默认情况下,当 WASI 应用调用 __wasi_proc_exit() 时,wasi.start() 将返回指定的退出代码,而不是终止进程。将此选项设置为 false 将导致 Node.js 进程以指定的退出代码退出。默认值:true

      ¥returnOnExit <boolean> By default, when WASI applications call __wasi_proc_exit() wasi.start() will return with the exit code specified rather than terminating the process. Setting this option to false will cause the Node.js process to exit with the specified exit code instead. Default: true.

    • stdin <integer> 在 WebAssembly 应用中用作标准输入的文件描述符。默认值:0

      ¥stdin <integer> The file descriptor used as standard input in the WebAssembly application. Default: 0.

    • stdout <integer> 在 WebAssembly 应用中用作标准输出的文件描述符。默认值:1

      ¥stdout <integer> The file descriptor used as standard output in the WebAssembly application. Default: 1.

    • stderr <integer> 在 WebAssembly 应用中用作标准错误的文件描述符。默认值:2

      ¥stderr <integer> The file descriptor used as standard error in the WebAssembly application. Default: 2.

    • version <string> 请求的 WASI 版本。目前唯一支持的版本是 unstablepreview1。此选项是强制性的。

      ¥version <string> The version of WASI requested. Currently the only supported versions are unstable and preview1. This option is mandatory.