Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/fs.ts>createWritableStream

A JavaScript extension package for building strong and modern applications.
Latest
function createWritableStream
import { createWritableStream } from "https://deno.land/x/ayonli_jsext@v0.9.72/fs.ts";

Creates a writable stream for the target file.

NOTE: In Node.js, this function requires Node.js v18.0 or above.

Examples

Example 1

// with the default storage
import { createWritableStream } from "@ayonli/jsext/fs";

const output = createWritableStream("/path/to/file.txt");
const res = await fetch("https://example.com/file.txt");

await res.body!.pipeTo(output);

Example 2

// with a user-selected directory as root (Chromium only)
import { createWritableStream } from "@ayonli/jsext/fs";

const root = await window.showDirectoryPicker();
const output = createWritableStream("/path/to/file.txt", { root });
const res = await fetch("https://example.com/file.txt");

await res.body!.pipeTo(output);

Parameters

target: string | FileSystemFileHandle
optional
options: Omit<WriteFileOptions, "signal"> = [UNSUPPORTED]