-
-
Save naartjie/132976f1361c9767ce66 to your computer and use it in GitHub Desktop.
async await
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
| async function walk (dir, visitor) { | |
| const filenames = await fs.readdirAsync(dir) | |
| await* filenames | |
| .map(filename => path.join(dir, filename)) | |
| .map(async filename => { | |
| const stat = await fs.statAsync(filename) | |
| if (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