Write File
Write a file to the currently loaded game project:
ts
import { Fs } from "@vaguevoid/tools";
await Fs.writeFile("assets/hello.txt", "Hello, World!");
Writing json is also supported:
ts
import { Fs } from "@vaguevoid/tools";
await Fs.writeFile("assets/great.json", { cool: "nice" });
As is writing binary data:
ts
import { Fs } from "@vaguevoid/tools";
await Fs.writeFile(
"assets/binary.bin",
new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
);
The writeFile
function will create any directories needed to write the file.
ts
import { Fs } from "@vaguevoid/tools";
await Fs.writeFile("some/deep/directory/file.txt", "Hello, World!");