Created
July 17, 2019 23:26
-
-
Save webdevwilson/eb92c66d102a6e87f281906daa227dc3 to your computer and use it in GitHub Desktop.
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
/** | |
* List the subdirectories in a directory | |
* @param p the path to the directory | |
*/ | |
function *listDirectories(p: string) { | |
return new Promise((resolve, reject) => { | |
fs.readdir(p, (err, files) => { | |
files.forEach(f => { | |
fs.stat(f, (err, stats) => { | |
if(stats.isDirectory()) | |
yield f | |
}) | |
}) | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment