Last active
November 8, 2022 18:34
-
-
Save qgustavor/1fc2530b96853c3ee9a027657be86e64 to your computer and use it in GitHub Desktop.
Recursive implementation of Deno.readDir
This file contains 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
export async function* recursiveReadDir (url) { | |
for await (const dirEntry of Deno.readDir(url)) { | |
if (dirEntry.isDirectory) { | |
yield * recursiveReadDir(new URL(dirEntry.name, url.href + '/')) | |
} else if (dirEntry.isFile) { | |
yield new URL(dirEntry.name, url.href + '/') | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment