doc: add example to fs.promises.readdir

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Conor ONeill authored and Shelley Vohr committed 2020-02-17 12:05:47 -08:00
1 parent f0ffa4cb80
commit b50a6cc54d
1 file changed
+12
+12
View File
@@ -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