Skip to content

Instantly share code, notes, and snippets.

@LeoDog896
Last active August 5, 2022 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LeoDog896/761ac29628aee5e40dbfd5d4fc7fcfea to your computer and use it in GitHub Desktop.
Save LeoDog896/761ac29628aee5e40dbfd5d4fc7fcfea to your computer and use it in GitHub Desktop.
Recursively read a directory in Deno
import { join } from "https://deno.land/std/path/mod.ts";
export async function* recursiveReaddir(
path: string
): AsyncGenerator<string, void> {
for await (const dirEntry of Deno.readDir(path)) {
if (dirEntry.isDirectory) {
yield* recursiveReaddir(join(path, dirEntry.name));
} else if (dirEntry.isFile) {
yield join(path, dirEntry.name);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment