Skip to content

Instantly share code, notes, and snippets.

@qgustavor
Last active November 8, 2022 18:34
Show Gist options
  • Save qgustavor/1fc2530b96853c3ee9a027657be86e64 to your computer and use it in GitHub Desktop.
Save qgustavor/1fc2530b96853c3ee9a027657be86e64 to your computer and use it in GitHub Desktop.
Recursive implementation of Deno.readDir
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