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

x/ayonli_jsext/esm/fs.js>readTree

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

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

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

const tree = await readTree("/path/to/dir");
console.log(tree);

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

target
optional
options = [UNSUPPORTED]