1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -05:00
denoland-deno/tests/specs/run/wasm_module/cjs_importing/setup.ts
David Sherret 8be2bbf074
feat: Wasm module support (#26668)
Support for Wasm modules.

Note this implements the standard where the default export is the
instance (not the module). The module will come later with source phase
imports.

```ts
import { add } from "./math.wasm";

console.log(add(1, 2));
```
2024-11-19 18:59:23 -05:00

7 lines
299 B
TypeScript

fetch("http://localhost:4545/wasm/math.wasm").then(async (response) => {
if (!response.ok) {
throw new Error(`Failed to fetch WASM module: ${response.statusText}`);
}
using file = Deno.openSync("math.wasm", { write: true, create: true });
await response.body!.pipeTo(file.writable);
});