Walking directories

When doing something like filesystem routing, it is useful to be able to walk down a directory to visit files.

for await (const dirEntry of Deno.readDir(".")) {
  console.log("Basic listing:", dirEntry.name);
}
import { walk } from "jsr:@std/fs/walk";

for await (const dirEntry of walk(".")) {
  console.log("Recursive walking:", dirEntry.name);
}
for await (const dirEntry of walk(".", { exts: ["ts"] })) {
  console.log("Recursive walking with extension:", dirEntry.name);
}

Run this example locally using the Deno CLI:

deno run -R https://docs.deno.com/examples/scripts/walking_directories.ts

Did you find what you needed?