Skip to content

Commit 65208d0

Browse files
iwkoTrott
authored andcommitted
doc: improve documentation of fs sync methods
Add links to async methods and make wording consistent. PR-URL: #21243 Refs: #21197 Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Jamie Davis <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent 0c743b5 commit 65208d0

File tree

1 file changed

+48
-15
lines changed

1 file changed

+48
-15
lines changed

doc/api/fs.md

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,8 +1137,8 @@ changes:
11371137
* `path` {string|Buffer|URL}
11381138
* `mode` {integer}
11391139

1140-
Synchronously changes the permissions of a file. Returns `undefined`.
1141-
This is the synchronous version of [`fs.chmod()`][].
1140+
For detailed information, see the documentation of the asynchronous version of
1141+
this API: [`fs.chmod()`][].
11421142

11431143
See also: chmod(2).
11441144

@@ -1567,13 +1567,16 @@ changes:
15671567
* `path` {string|Buffer|URL}
15681568
* Returns: {boolean}
15691569

1570-
Synchronous version of [`fs.exists()`][].
15711570
Returns `true` if the path exists, `false` otherwise.
15721571

1572+
For detailed information, see the documentation of the asynchronous version of
1573+
this API: [`fs.exists()`][].
1574+
15731575
`fs.exists()` is deprecated, but `fs.existsSync()` is not. The `callback`
15741576
parameter to `fs.exists()` accepts parameters that are inconsistent with other
15751577
Node.js callbacks. `fs.existsSync()` does not use a callback.
15761578

1579+
15771580
## fs.fchmod(fd, mode, callback)
15781581
<!-- YAML
15791582
added: v0.4.7
@@ -1820,7 +1823,10 @@ added: v0.8.6
18201823
* `fd` {integer}
18211824
* `len` {integer} **Default:** `0`
18221825

1823-
Synchronous ftruncate(2). Returns `undefined`.
1826+
Returns `undefined`.
1827+
1828+
For detailed information, see the documentation of the asynchronous version of
1829+
this API: [`fs.ftruncate()`][].
18241830

18251831
## fs.futimes(fd, atime, mtime, callback)
18261832
<!-- YAML
@@ -2170,8 +2176,10 @@ added: v5.10.0
21702176
* `encoding` {string} **Default:** `'utf8'`
21712177
* Returns: {string}
21722178

2173-
The synchronous version of [`fs.mkdtemp()`][]. Returns the created
2174-
folder path.
2179+
Returns the created folder path.
2180+
2181+
For detailed information, see the documentation of the asynchronous version of
2182+
this API: [`fs.mkdtemp()`][].
21752183

21762184
The optional `options` argument can be a string specifying an encoding, or an
21772185
object with an `encoding` property specifying the character encoding to use.
@@ -2227,8 +2235,10 @@ changes:
22272235
* `mode` {integer} **Default:** `0o666`
22282236
* Returns: {number}
22292237

2230-
Synchronous version of [`fs.open()`][]. Returns an integer representing the file
2231-
descriptor.
2238+
Returns an integer representing the file descriptor.
2239+
2240+
For detailed information, see the documentation of the asynchronous version of
2241+
this API: [`fs.open()`][].
22322242

22332243
## fs.read(fd, buffer, offset, length, position, callback)
22342244
<!-- YAML
@@ -2426,7 +2436,10 @@ changes:
24262436
* `flag` {string} See [support of file system `flags`][]. **Default:** `'r'`.
24272437
* Returns: {string|Buffer}
24282438

2429-
Synchronous version of [`fs.readFile()`][]. Returns the contents of the `path`.
2439+
Returns the contents of the `path`.
2440+
2441+
For detailed information, see the documentation of the asynchronous version of
2442+
this API: [`fs.readFile()`][].
24302443

24312444
If the `encoding` option is specified then this function returns a
24322445
string. Otherwise it returns a buffer.
@@ -2514,7 +2527,10 @@ changes:
25142527
* `position` {integer}
25152528
* Returns: {number}
25162529

2517-
Synchronous version of [`fs.read()`][]. Returns the number of `bytesRead`.
2530+
Returns the number of `bytesRead`.
2531+
2532+
For detailed information, see the documentation of the asynchronous version of
2533+
this API: [`fs.read()`][].
25182534

25192535
## fs.realpath(path[, options], callback)
25202536
<!-- YAML
@@ -2629,7 +2645,10 @@ changes:
26292645
* `encoding` {string} **Default:** `'utf8'`
26302646
* Returns: {string|Buffer}
26312647

2632-
Synchronous version of [`fs.realpath()`][]. Returns the resolved pathname.
2648+
Returns the resolved pathname.
2649+
2650+
For detailed information, see the documentation of the asynchronous version of
2651+
this API: [`fs.realpath()`][].
26332652

26342653
## fs.realpathSync.native(path[, options])
26352654
<!-- YAML
@@ -2865,7 +2884,10 @@ changes:
28652884
* `path` {string|Buffer|URL}
28662885
* `type` {string} **Default:** `'file'`
28672886

2868-
Synchronous symlink(2). Returns `undefined`.
2887+
Returns `undefined`.
2888+
2889+
For detailed information, see the documentation of the asynchronous version of
2890+
this API: [`fs.symlink()`][].
28692891

28702892
## fs.truncate(path[, len], callback)
28712893
<!-- YAML
@@ -3041,7 +3063,10 @@ changes:
30413063
* `atime` {integer}
30423064
* `mtime` {integer}
30433065

3044-
Synchronous version of [`fs.utimes()`][]. Returns `undefined`.
3066+
Returns `undefined`.
3067+
3068+
For detailed information, see the documentation of the asynchronous version of
3069+
this API: [`fs.utimes()`][].
30453070

30463071
## fs.watch(filename[, options][, listener])
30473072
<!-- YAML
@@ -3392,7 +3417,10 @@ changes:
33923417
* `mode` {integer} **Default:** `0o666`
33933418
* `flag` {string} See [support of file system `flags`][]. **Default:** `'w'`.
33943419

3395-
The synchronous version of [`fs.writeFile()`][]. Returns `undefined`.
3420+
Returns `undefined`.
3421+
3422+
For detailed information, see the documentation of the asynchronous version of
3423+
this API: [`fs.writeFile()`][].
33963424

33973425
## fs.writeSync(fd, buffer[, offset[, length[, position]]])
33983426
<!-- YAML
@@ -3428,7 +3456,10 @@ changes:
34283456
* `encoding` {string}
34293457
* Returns: {number}
34303458

3431-
Synchronous versions of [`fs.write()`][]. Returns the number of bytes written.
3459+
Returns the number of bytes written.
3460+
3461+
For detailed information, see the documentation of the asynchronous version of
3462+
this API: [`fs.write()`][].
34323463

34333464
## fs Promises API
34343465

@@ -4593,6 +4624,7 @@ the file contents.
45934624
[`fs.copyFile()`]: #fs_fs_copyfile_src_dest_flags_callback
45944625
[`fs.exists()`]: fs.html#fs_fs_exists_path_callback
45954626
[`fs.fstat()`]: #fs_fs_fstat_fd_options_callback
4627+
[`fs.ftruncate()`]: #fs_fs_ftruncate_fd_len_callback
45964628
[`fs.futimes()`]: #fs_fs_futimes_fd_atime_mtime_callback
45974629
[`fs.lstat()`]: #fs_fs_lstat_path_options_callback
45984630
[`fs.mkdir()`]: #fs_fs_mkdir_path_mode_callback
@@ -4604,6 +4636,7 @@ the file contents.
46044636
[`fs.realpath()`]: #fs_fs_realpath_path_options_callback
46054637
[`fs.rmdir()`]: #fs_fs_rmdir_path_callback
46064638
[`fs.stat()`]: #fs_fs_stat_path_options_callback
4639+
[`fs.symlink()`]: #fs_fs_symlink_target_path_type_callback
46074640
[`fs.utimes()`]: #fs_fs_utimes_path_atime_mtime_callback
46084641
[`fs.watch()`]: #fs_fs_watch_filename_options_listener
46094642
[`fs.write()`]: #fs_fs_write_fd_buffer_offset_length_position_callback

0 commit comments

Comments
 (0)