Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4929,6 +4929,20 @@ will be passed as `Buffer` objects.
If `options.withFileTypes` is set to `true`, the resolved array will contain
[`fs.Dirent`][] objects.

Example iterating over a directory listing:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably omit this line and simply show the example code. If you want to include // Iterate over a directory listing. as a comment in the example code, that would be better IMO. The example code and surrounding text should be related but independent.


```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