import { readTree } from "https://deno.land/x/ayonli_jsext@v0.9.72/fs.ts";
Recursively reads the contents of the directory and transform them into a tree structure.
NOTE: Unlike readDir, the order of the entries returned by this function is guaranteed, they are ordered first by kind (directories before files), then by names alphabetically.
NOTE: This function can also be used in Cloudflare Workers.
Examples
Example 1
Example 1
// with the default storage
import { readTree } from "@ayonli/jsext/fs";
const tree = await readTree("/path/to/dir");
console.log(tree);
Example 2
Example 2
// with a user-selected directory as root (Chromium only)
import { readTree } from "@ayonli/jsext/fs";
const root = await window.showDirectoryPicker();
const tree = await readTree("/path/to/dir", { root });
console.log(tree);
Parameters
optional
options: FileSystemOptions = [UNSUPPORTED]