Skip to content

Commit

Permalink
Merge branch 'main' into feat/avatar-tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
ovflowd authored Oct 31, 2024
2 parents 728bfde + d97bede commit 1d1587d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
9 changes: 9 additions & 0 deletions apps/site/next-data/generators/__tests__/releaseData.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ import generateReleaseData from '@/next-data/generators/releaseData.mjs';
jest.mock('@nodevu/core');

describe('generateReleaseData', () => {
beforeAll(() => {
jest.useFakeTimers();
jest.setSystemTime(new Date('2024-10-18'));
});

afterAll(() => {
jest.useRealTimers();
});

test('generates release data with correct status', async () => {
const mockNodevuOutput = {
14: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,36 @@ Once you have a WebAssembly module, you can use the Node.js `WebAssembly` object
// Assume add.wasm file exists that contains a single function adding 2 provided arguments
const fs = require('node:fs');

// Use the readFileSync function to read the contents of the "add.wasm" file
const wasmBuffer = fs.readFileSync('/path/to/add.wasm');

// Use the WebAssembly.instantiate method to instantiate the WebAssembly module
WebAssembly.instantiate(wasmBuffer).then(wasmModule => {
// Exported function live under instance.exports
// Exported function lives under instance.exports object
const { add } = wasmModule.instance.exports;
const sum = add(5, 6);
console.log(sum); // Outputs: 11
});
```

```mjs
// Assume add.wasm file exists that contains a single function adding 2 provided arguments
import fs from 'node:fs/promises';

// Use readFile to read contents of the "add.wasm" file
const wasmBuffer = await fs.readFile('path/to/add.wsm');

// Use the WebAssembly.instantiate method to instantiate the WebAssembly module
const wasmModule = await WebAssembly.instantiate(wasmBuffer);

// Exported function lives under instance.exports object
const { add } = wasmModule.instance.exports;

const sum = add(5, 6);

console.log(sum); // Outputs 11
```

## Interacting with the OS

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.
Expand Down

0 comments on commit 1d1587d

Please sign in to comment.