Skip to content

Commit ec14c64

Browse files
authored
Merge branch 'main' into chore/nextjs-15
2 parents efe47d3 + d97bede commit ec14c64

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

apps/site/next-data/generators/__tests__/releaseData.test.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ import generateReleaseData from '@/next-data/generators/releaseData.mjs';
1010
jest.mock('@nodevu/core');
1111

1212
describe('generateReleaseData', () => {
13+
beforeAll(() => {
14+
jest.useFakeTimers();
15+
jest.setSystemTime(new Date('2024-10-18'));
16+
});
17+
18+
afterAll(() => {
19+
jest.useRealTimers();
20+
});
21+
1322
test('generates release data with correct status', async () => {
1423
const mockNodevuOutput = {
1524
14: {

apps/site/pages/en/learn/getting-started/nodejs-with-webassembly.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,36 @@ Once you have a WebAssembly module, you can use the Node.js `WebAssembly` object
4949
// Assume add.wasm file exists that contains a single function adding 2 provided arguments
5050
const fs = require('node:fs');
5151

52+
// Use the readFileSync function to read the contents of the "add.wasm" file
5253
const wasmBuffer = fs.readFileSync('/path/to/add.wasm');
54+
55+
// Use the WebAssembly.instantiate method to instantiate the WebAssembly module
5356
WebAssembly.instantiate(wasmBuffer).then(wasmModule => {
54-
// Exported function live under instance.exports
57+
// Exported function lives under instance.exports object
5558
const { add } = wasmModule.instance.exports;
5659
const sum = add(5, 6);
5760
console.log(sum); // Outputs: 11
5861
});
5962
```
6063

64+
```mjs
65+
// Assume add.wasm file exists that contains a single function adding 2 provided arguments
66+
import fs from 'node:fs/promises';
67+
68+
// Use readFile to read contents of the "add.wasm" file
69+
const wasmBuffer = await fs.readFile('path/to/add.wsm');
70+
71+
// Use the WebAssembly.instantiate method to instantiate the WebAssembly module
72+
const wasmModule = await WebAssembly.instantiate(wasmBuffer);
73+
74+
// Exported function lives under instance.exports object
75+
const { add } = wasmModule.instance.exports;
76+
77+
const sum = add(5, 6);
78+
79+
console.log(sum); // Outputs 11
80+
```
81+
6182
## Interacting with the OS
6283

6384
WebAssembly modules cannot directly access OS functionality on its own. A third-party tool [Wasmtime](https://docs.wasmtime.dev/) can be used to access this functionality. `Wasmtime` utilizes the [WASI](https://wasi.dev/) API to access the OS functionality.

0 commit comments

Comments
 (0)