Skip to content

Commit 7e911d8

Browse files
conoroaddaleax
authored andcommitted
doc: add example to fs.promises.readdir
PR-URL: nodejs#31552 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent c1da4e4 commit 7e911d8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

doc/api/fs.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4972,6 +4972,18 @@ will be passed as `Buffer` objects.
49724972
If `options.withFileTypes` is set to `true`, the resolved array will contain
49734973
[`fs.Dirent`][] objects.
49744974

4975+
```js
4976+
const fs = require('fs');
4977+
4978+
async function print(path) {
4979+
const files = await fs.promises.readdir(path);
4980+
for (const file of files) {
4981+
console.log(file);
4982+
}
4983+
}
4984+
print('./').catch(console.error);
4985+
```
4986+
49754987
### `fsPromises.readFile(path[, options])`
49764988
<!-- YAML
49774989
added: v10.0.0

0 commit comments

Comments
 (0)