diff --git a/doc/api/fs.md b/doc/api/fs.md index 6b07c2311eb5c3..662d60bfb378a5 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -4921,6 +4921,18 @@ will be passed as `Buffer` objects. If `options.withFileTypes` is set to `true`, the resolved array will contain [`fs.Dirent`][] objects. +```js +const fs = require('fs'); + +async function print(path) { + const files = await fs.promises.readdir(path); + for (const file of files) { + console.log(file); + } +} +print('./').catch(console.error); +``` + ### `fsPromises.readFile(path[, options])`