Ende.writeFile

function ยท requires --allow-read, --allow-write

function Ende.writeFile(path: string | URL, data: Uint8Array | ReadableStream<Uint8Array>, options?: WriteFileOptions): Promise<void>

Write data to the given path, by default creating a new file if needed, else overwriting.

const encoder = new TextEncoder();
const data = encoder.encode("Hello world\n");
await Ende.writeFile("hello1.txt", data);  // overwrite "hello1.txt" or create it
await Ende.writeFile("hello2.txt", data, { create: false });  // only works if "hello2.txt" exists
await Ende.writeFile("hello3.txt", data, { mode: 0o777 });  // set permissions on new file
await Ende.writeFile("hello4.txt", data, { append: true });  // add data to the end of the file

Requires allow-write permission, and allow-read if options.create is false.