Skip to main content

property Deno.FsFile.prototype.writable

A WritableStream instance to write the contents of the file. This makes it easy to interoperate with other web streams based APIs.

const items = ["hello", "world"];
using file = await Deno.open("my_file.txt", { write: true });
const encoder = new TextEncoder();
const writer = file.writable.getWriter();
for (const item of items) {
  await writer.write(encoder.encode(item));
}

Note that the writable stream takes ownership of the file: closing or aborting the stream closes the file automatically, so you should not close the file yourself while the stream is still in use.

Type #

WritableStream<Uint8Array<ArrayBufferLike>>

Did you find what you needed?

Privacy policy