Skip to content

Commit c66bc20

Browse files
vsemozhetbyttargos
authored andcommitted
doc: fix some recent nits in fs.md
* Fix sorting of sections. * Fix sorting of bottom references. * Wrap lines at 80 chars. * Fix a heading level. PR-URL: #29906 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent e175d0b commit c66bc20

File tree

1 file changed

+44
-42
lines changed

1 file changed

+44
-42
lines changed

doc/api/fs.md

+44-42
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ added: v12.12.0
291291

292292
A class representing a directory stream.
293293

294-
Created by [`fs.opendir()`][], [`fs.opendirSync()`][], or [`fsPromises.opendir()`][].
294+
Created by [`fs.opendir()`][], [`fs.opendirSync()`][], or
295+
[`fsPromises.opendir()`][].
295296

296297
```js
297298
const fs = require('fs');
@@ -305,16 +306,6 @@ async function print(path) {
305306
print('./').catch(console.error);
306307
```
307308

308-
### dir.path
309-
<!-- YAML
310-
added: v12.12.0
311-
-->
312-
313-
* {string}
314-
315-
The read-only path of this directory as was provided to [`fs.opendir()`][],
316-
[`fs.opendirSync()`][], or [`fsPromises.opendir()`][].
317-
318309
### dir.close()
319310
<!-- YAML
320311
added: v12.12.0
@@ -349,6 +340,16 @@ added: v12.12.0
349340
Synchronously close the directory's underlying resource handle.
350341
Subsequent reads will result in errors.
351342

343+
### dir.path
344+
<!-- YAML
345+
added: v12.12.0
346+
-->
347+
348+
* {string}
349+
350+
The read-only path of this directory as was provided to [`fs.opendir()`][],
351+
[`fs.opendirSync()`][], or [`fsPromises.opendir()`][].
352+
352353
### dir.read()
353354
<!-- YAML
354355
added: v12.12.0
@@ -429,7 +430,8 @@ included in the iteration results.
429430
added: v10.10.0
430431
-->
431432

432-
A representation of a directory entry, as returned by reading from an [`fs.Dir`][].
433+
A representation of a directory entry, as returned by reading from an
434+
[`fs.Dir`][].
433435

434436
Additionally, when [`fs.readdir()`][] or [`fs.readdirSync()`][] is called with
435437
the `withFileTypes` option set to `true`, the resulting array is filled with
@@ -2620,33 +2622,6 @@ a colon, Node.js will open a file system stream, as described by
26202622
Functions based on `fs.open()` exhibit this behavior as well:
26212623
`fs.writeFile()`, `fs.readFile()`, etc.
26222624

2623-
## fs.openSync(path\[, flags, mode\])
2624-
<!-- YAML
2625-
added: v0.1.21
2626-
changes:
2627-
- version: v11.1.0
2628-
pr-url: https://github.com/nodejs/node/pull/23767
2629-
description: The `flags` argument is now optional and defaults to `'r'`.
2630-
- version: v9.9.0
2631-
pr-url: https://github.com/nodejs/node/pull/18801
2632-
description: The `as` and `as+` modes are supported now.
2633-
- version: v7.6.0
2634-
pr-url: https://github.com/nodejs/node/pull/10739
2635-
description: The `path` parameter can be a WHATWG `URL` object using `file:`
2636-
protocol. Support is currently still *experimental*.
2637-
-->
2638-
2639-
* `path` {string|Buffer|URL}
2640-
* `flags` {string|number} **Default:** `'r'`.
2641-
See [support of file system `flags`][].
2642-
* `mode` {integer} **Default:** `0o666`
2643-
* Returns: {number}
2644-
2645-
Returns an integer representing the file descriptor.
2646-
2647-
For detailed information, see the documentation of the asynchronous version of
2648-
this API: [`fs.open()`][].
2649-
26502625
## fs.opendir(path\[, options\], callback)
26512626
<!-- YAML
26522627
added: v12.12.0
@@ -2685,6 +2660,33 @@ and cleaning up the directory.
26852660
The `encoding` option sets the encoding for the `path` while opening the
26862661
directory and subsequent read operations.
26872662

2663+
## fs.openSync(path\[, flags, mode\])
2664+
<!-- YAML
2665+
added: v0.1.21
2666+
changes:
2667+
- version: v11.1.0
2668+
pr-url: https://github.com/nodejs/node/pull/23767
2669+
description: The `flags` argument is now optional and defaults to `'r'`.
2670+
- version: v9.9.0
2671+
pr-url: https://github.com/nodejs/node/pull/18801
2672+
description: The `as` and `as+` modes are supported now.
2673+
- version: v7.6.0
2674+
pr-url: https://github.com/nodejs/node/pull/10739
2675+
description: The `path` parameter can be a WHATWG `URL` object using `file:`
2676+
protocol. Support is currently still *experimental*.
2677+
-->
2678+
2679+
* `path` {string|Buffer|URL}
2680+
* `flags` {string|number} **Default:** `'r'`.
2681+
See [support of file system `flags`][].
2682+
* `mode` {integer} **Default:** `0o666`
2683+
* Returns: {number}
2684+
2685+
Returns an integer representing the file descriptor.
2686+
2687+
For detailed information, see the documentation of the asynchronous version of
2688+
this API: [`fs.open()`][].
2689+
26882690
## fs.read(fd, buffer, offset, length, position, callback)
26892691
<!-- YAML
26902692
added: v0.0.2
@@ -4824,7 +4826,7 @@ by [Naming Files, Paths, and Namespaces][]. Under NTFS, if the filename contains
48244826
a colon, Node.js will open a file system stream, as described by
48254827
[this MSDN page][MSDN-Using-Streams].
48264828

4827-
## fsPromises.opendir(path\[, options\])
4829+
### fsPromises.opendir(path\[, options\])
48284830
<!-- YAML
48294831
added: v12.12.0
48304832
-->
@@ -5459,6 +5461,7 @@ the file contents.
54595461
[`Buffer.byteLength`]: buffer.html#buffer_class_method_buffer_bytelength_string_encoding
54605462
[`Buffer`]: buffer.html#buffer_buffer
54615463
[`FSEvents`]: https://developer.apple.com/documentation/coreservices/file_system_events
5464+
[`Number.MAX_SAFE_INTEGER`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
54625465
[`ReadDirectoryChangesW`]: https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-readdirectorychangesw
54635466
[`ReadStream`]: #fs_class_fs_readstream
54645467
[`URL`]: url.html#url_the_whatwg_url_api
@@ -5505,7 +5508,6 @@ the file contents.
55055508
[`net.Socket`]: net.html#net_class_net_socket
55065509
[`stat()`]: fs.html#fs_fs_stat_path_options_callback
55075510
[`util.promisify()`]: util.html#util_util_promisify_original
5508-
[bigints]: https://tc39.github.io/proposal-bigint
55095511
[Caveats]: #fs_caveats
55105512
[Common System Errors]: errors.html#errors_common_system_errors
55115513
[FS Constants]: #fs_fs_constants_1
@@ -5515,7 +5517,7 @@ the file contents.
55155517
[MSDN-Rel-Path]: https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#fully-qualified-vs-relative-paths
55165518
[MSDN-Using-Streams]: https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams
55175519
[Naming Files, Paths, and Namespaces]: https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file
5520+
[bigints]: https://tc39.github.io/proposal-bigint
55185521
[chcp]: https://ss64.com/nt/chcp.html
55195522
[inode]: https://en.wikipedia.org/wiki/Inode
55205523
[support of file system `flags`]: #fs_file_system_flags
5521-
[`Number.MAX_SAFE_INTEGER`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER

0 commit comments

Comments
 (0)