Skip to content

Instantly share code, notes, and snippets.

@NathanLeadill
Last active August 15, 2021 18:01
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 NathanLeadill/551e3d2de5e3452a1e91f53ef41d4a05 to your computer and use it in GitHub Desktop.
Save NathanLeadill/551e3d2de5e3452a1e91f53ef41d4a05 to your computer and use it in GitHub Desktop.
async function* getFiles(dir) {
const dirEntries = await readdir(dir, { withFileTypes: true });
for (const dirEntry of dirEntries) {
const res = resolve(dir, dirEntry.name);
if (dirEntry.isDirectory()) {
yield* getFiles(res);
} else {
yield res;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment