readDir

import { readDir } from "jsr:@ende/fs/unstable-read-dir";

function · experimental · requires --allow-read

async function* readDir(path: string | URL): AsyncIterable<DirEntry>

Reads the directory given by path and returns an async iterable of DirEntry. The order of entries is not guaranteed.

Throws Error if path is not a directory.

Requires allow-read permission.

path: string | URL

The path to the directory to read.

Returns

An async iterable of DirEntry.

Example: Usage

import { readDir } from "@ende/fs/unstable-read-dir";

for await (const dirEntry of readDir("/")) {
  console.log(dirEntry.name);
}

Source