import { createReadableStream } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/fs.js";
Creates a readable stream for the target file.
NOTE: In Node.js, this function requires Node.js v18.0 or above.
Examples
Example 1
Example 1
// with the default storage
import { createReadableStream } from "@ayonli/jsext/fs";
import { readAsText } from "@ayonli/jsext/reader";
const input = createReadableStream("/path/to/file.txt");
const text = await readAsText(input);
console.log(text);
Example 2
Example 2
// with a user-selected directory as root (Chromium only)
import { createReadableStream } from "@ayonli/jsext/fs";
import { readAsText } from "@ayonli/jsext/reader";
const root = await window.showDirectoryPicker();
const input = createReadableStream("/path/to/file.txt", { root });
const text = await readAsText(input);
console.log(text);