Skip to content

Commit 06d5a9c

Browse files
conorocodebytere
authored andcommitted
doc: add example to fs.promises.readdir
PR-URL: #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 2cdd57a commit 06d5a9c

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
@@ -4921,6 +4921,18 @@ will be passed as `Buffer` objects.
49214921
If `options.withFileTypes` is set to `true`, the resolved array will contain
49224922
[`fs.Dirent`][] objects.
49234923

4924+
```js
4925+
constfs=require('fs');
4926+
4927+
asyncfunctionprint(path){
4928+
constfiles=awaitfs.promises.readdir(path);
4929+
for (constfileof files){
4930+
console.log(file);
4931+
}
4932+
}
4933+
print('./').catch(console.error);
4934+
```
4935+
49244936
### `fsPromises.readFile(path[, options])`
49254937
<!-- YAML
49264938
added: v10.0.0

0 commit comments

Comments
(0)