Last active
December 7, 2023 14:38
-
-
Save nebomilic/91560bafefe3ac8cea00052e6bc28439 to your computer and use it in GitHub Desktop.
Async reading directory content with fs.readdir in Typescript
This file contains 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
import fs from 'fs' | |
export const listFilesInDirectory = async (path: string) => | |
new Promise((resolve, reject) => | |
fs.readdir(path, (err, content) => | |
err ? reject(err) : resolve(content) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Async reading directory content with fs.readdir in Typescript (Another similar alternative way to @nebomilic)