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 <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
conoro authored and codebytere committed Feb 17, 2020
1 parent f0ffa4c commit b50a6cc
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 @@ -4941,6 +4941,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 b50a6cc

Please sign in to comment.