diff options
-rw-r--r-- | std/wasi/README.md | 8 | ||||
-rw-r--r-- | std/wasi/snapshot_preview1.ts | 6 | ||||
-rw-r--r-- | std/wasi/snapshot_preview1_test.ts | 8 |
3 files changed, 11 insertions, 11 deletions
diff --git a/std/wasi/README.md b/std/wasi/README.md index 4cbcbbca3..580e7ddd0 100644 --- a/std/wasi/README.md +++ b/std/wasi/README.md @@ -55,9 +55,9 @@ This module provides an implementation of the WebAssembly System Interface ## Usage ```typescript -import WASI from "https://deno.land/std/wasi/snapshot_preview1.ts"; +import Context from "https://deno.land/std/wasi/snapshot_preview1.ts"; -const wasi = new WASI({ +const context = new Context({ args: Deno.args, env: Deno.env, }); @@ -65,10 +65,10 @@ const wasi = new WASI({ const binary = await Deno.readFile("path/to/your/module.wasm"); const module = await WebAssembly.compile(binary); const instance = await WebAssembly.instantiate(module, { - wasi_snapshot_preview1: wasi.exports, + wasi_snapshot_preview1: context.exports, }); -wasi.memory = instance.exports.memory; +context.memory = context.exports.memory; if (module.exports._start) { instance.exports._start(); diff --git a/std/wasi/snapshot_preview1.ts b/std/wasi/snapshot_preview1.ts index 0e32e3a2b..ab9da73ec 100644 --- a/std/wasi/snapshot_preview1.ts +++ b/std/wasi/snapshot_preview1.ts @@ -277,14 +277,14 @@ function errno(err: Error) { } } -export interface ModuleOptions { +export interface ContextOptions { args?: string[]; env?: { [key: string]: string | undefined }; preopens?: { [key: string]: string }; memory?: WebAssembly.Memory; } -export default class Module { +export default class Context { args: string[]; env: { [key: string]: string | undefined }; memory: WebAssembly.Memory; @@ -294,7 +294,7 @@ export default class Module { exports: Record<string, Function>; - constructor(options: ModuleOptions) { + constructor(options: ContextOptions) { this.args = options.args ? options.args : []; this.env = options.env ? options.env : {}; this.memory = options.memory!; diff --git a/std/wasi/snapshot_preview1_test.ts b/std/wasi/snapshot_preview1_test.ts index 748ba7772..dce37d220 100644 --- a/std/wasi/snapshot_preview1_test.ts +++ b/std/wasi/snapshot_preview1_test.ts @@ -2,24 +2,24 @@ import { assert, assertEquals } from "../testing/asserts.ts"; import * as path from "../path/mod.ts"; -import WASI from "./snapshot_preview1.ts"; +import Context from "./snapshot_preview1.ts"; if (import.meta.main) { const options = JSON.parse(Deno.args[0]); const binary = await Deno.readFile(Deno.args[1]); const module = await WebAssembly.compile(binary); - const wasi = new WASI({ + const context = new Context({ env: options.env, args: options.args, preopens: options.preopens, }); const instance = new WebAssembly.Instance(module, { - wasi_snapshot_preview1: wasi.exports, + wasi_snapshot_preview1: context.exports, }); - wasi.memory = instance.exports.memory; + context.memory = instance.exports.memory; instance.exports._start(); } else { |