Skip to content

Instantly share code, notes, and snippets.

@RReverser
Last active August 29, 2015 14:21
Show Gist options
  • Save RReverser/0a0263ec5abc5db03e05 to your computer and use it in GitHub Desktop.
Save RReverser/0a0263ec5abc5db03e05 to your computer and use it in GitHub Desktop.
async function walk (dir, visitor) {
const filenames = await fs.readdirAsync(dir);
await* filenames.map(async _filename => {
const filename = path.join(dir, _filename);
const stat = await fs.statAsync(filename);
if (stat && stat.isDirectory()) {
await walk(filename, visitor);
} else {
visitor(filename, stat);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment