@wasmer/wasmfs
The filesystem for Wasm!
import { WasmFs } from "@wasmer/wasmfs"
.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
wasmFs.fs: MemFs
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 operationsconst wasmFs = new WasmFs();
const originalWriteFileSync = wasmFs.fs.writeFileSync;
wasmFs.fs.writeFileSync = (path, text) => {
console.log("File written:", path);
originalWriteFileSync(path, text);
};
wasmFs.fs.writeFileSync("/dev/stdout", "Quick Start!");
// Would log: "File written: /dev/stdout"
wasmFs.getStdOut(): string
Returns the current standard output (
/dev/stdout
) of the filesystem.Last modified 1yr ago