@wasmer/wasmfs
The filesystem for Wasm!

WasmFS

import { WasmFs } from "@wasmer/wasmfs".

Constructor

new WasmFs(): WasmFs
Constructor that returns a WasmFs instance.
Please see the section below on instance properties to see a list of the properties on the returned instance

Instance Properties

fs

wasmFs.fs: MemFs
​memfs' node fs implementation object. See the node fs documentation for API usage.
NOTE: The functions on this fs implementation can easily be over-ridden to provide custom functionality when your Wasm module (running with @wasmer/wasi) tries to do file system operations
1
const wasmFs = new WasmFs();
2
​
3
const originalWriteFileSync = wasmFs.fs.writeFileSync;
4
wasmFs.fs.writeFileSync = (path, text) => {
5
console.log("File written:", path);
6
originalWriteFileSync(path, text);
7
};
8
​
9
wasmFs.fs.writeFileSync("/dev/stdout", "Quick Start!");
10
​
11
// Would log: "File written: /dev/stdout"
Copied!

getStdOut

wasmFs.getStdOut(): string
Returns the current standard output (/dev/stdout) of the filesystem.
Last modified 25d ago