Created
September 25, 2022 16:29
-
-
Save Ivannnnn/d1c88bc319caec8f70647467d82b1f47 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
const path = require("path"); | |
function* walkSync(dir) { | |
const files = fs.readdirSync(dir, { withFileTypes: true }); | |
for (const file of files) { | |
file.isDirectory() | |
? yield* walkSync(path.join(dir, file.name)) | |
: yield path.join(dir, file.name); | |
} | |
} | |
const readDirRecursive = (dir) => [...walkSync(dir)]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment