Last active
August 5, 2022 15:38
-
-
Save tristan-f-r/761ac29628aee5e40dbfd5d4fc7fcfea to your computer and use it in GitHub Desktop.
Recursively read a directory in Deno
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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