new WASI([options])


  • options <Object>
    • args <Array> 第一个参数是 WASI 命令本身的虚拟路径。 默认值: []
    • env <Object> 类似于 process.env 的对象,WebAssembly 应用程序将其视为其环境。 默认值: {}
    • preopens <Object> 此对象表示 WebAssembly 应用程序的沙箱目录结构。 preopens 的字符串键被视为沙箱中的目录。 preopens 中对应的值是宿主机上这些目录的真实路径。
    • returnOnExit <boolean> 默认情况下,WASI 应用程序通过 __wasi_proc_exit() 函数终止 Node.js 进程。 将此选项设置为 true 会导致 wasi.start() 返回退出代码而不是终止进程。 默认值: false
    • stdin <integer> 在 WebAssembly 应用程序中用作标准输入的文件描述符。 默认值: 0
    • stdout <integer> 在 WebAssembly 应用程序中用作标准输出的文件描述符。 默认值: 1
    • stderr <integer> 在 WebAssembly 应用程序中用作标准错误的文件描述符。 默认值: 2
  • options <Object>
    • 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> An object similar to process.env that the WebAssembly application will see as its environment. Default: {}.
    • preopens <Object> This object represents the WebAssembly application's sandbox directory structure. The string keys of preopens are treated as directories within the sandbox. The corresponding values in preopens are the real paths to those directories on the host machine.
    • returnOnExit <boolean> By default, WASI applications terminate the Node.js process via the __wasi_proc_exit() function. Setting this option to true causes wasi.start() to return the exit code rather than terminate the process. Default: false.
    • stdin <integer> The file descriptor used as standard input in the WebAssembly application. Default: 0.
    • stdout <integer> The file descriptor used as standard output in the WebAssembly application. Default: 1.
    • stderr <integer> The file descriptor used as standard error in the WebAssembly application. Default: 2.