Skip to content

Commit

Permalink
doc: add example to fs.promises.readdir
Browse files Browse the repository at this point in the history
PR-URL: #31552
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
conoro authored and codebytere committed Mar 30, 2020
1 parent 2cdd57a commit 06d5a9c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])`
<!-- YAML
added: v10.0.0
Expand Down

0 comments on commit 06d5a9c

Please sign in to comment.