Skip to content

Commit cd77d87

Browse files
iwkotargos
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 b8ba003 commit cd77d87

File tree

1 file changed

+48
-15
lines changed

1 file changed

+48
-15
lines changed

doc/api/fs.md

+48-15
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

@@ -1562,13 +1562,16 @@ changes:
15621562
* `path` {string|Buffer|URL}
15631563
* Returns: {boolean}
15641564

1565-
Synchronous version of [`fs.exists()`][].
15661565
Returns `true` if the path exists, `false` otherwise.
15671566

1567+
For detailed information, see the documentation of the asynchronous version of
1568+
this API: [`fs.exists()`][].
1569+
15681570
`fs.exists()` is deprecated, but `fs.existsSync()` is not. The `callback`
15691571
parameter to `fs.exists()` accepts parameters that are inconsistent with other
15701572
Node.js callbacks. `fs.existsSync()` does not use a callback.
15711573

1574+
15721575
## fs.fchmod(fd, mode, callback)
15731576
<!-- YAML
15741577
added: v0.4.7
@@ -1815,7 +1818,10 @@ added: v0.8.6
18151818
* `fd` {integer}
18161819
* `len` {integer} **Default:** `0`
18171820

1818-
Synchronous ftruncate(2). Returns `undefined`.
1821+
Returns `undefined`.
1822+
1823+
For detailed information, see the documentation of the asynchronous version of
1824+
this API: [`fs.ftruncate()`][].
18191825

18201826
## fs.futimes(fd, atime, mtime, callback)
18211827
<!-- YAML
@@ -2165,8 +2171,10 @@ added: v5.10.0
21652171
* `encoding` {string} **Default:** `'utf8'`
21662172
* Returns: {string}
21672173

2168-
The synchronous version of [`fs.mkdtemp()`][]. Returns the created
2169-
folder path.
2174+
Returns the created folder path.
2175+
2176+
For detailed information, see the documentation of the asynchronous version of
2177+
this API: [`fs.mkdtemp()`][].
21702178

21712179
The optional `options` argument can be a string specifying an encoding, or an
21722180
object with an `encoding` property specifying the character encoding to use.
@@ -2222,8 +2230,10 @@ changes:
22222230
* `mode` {integer} **Default:** `0o666`
22232231
* Returns: {number}
22242232

2225-
Synchronous version of [`fs.open()`][]. Returns an integer representing the file
2226-
descriptor.
2233+
Returns an integer representing the file descriptor.
2234+
2235+
For detailed information, see the documentation of the asynchronous version of
2236+
this API: [`fs.open()`][].
22272237

22282238
## fs.read(fd, buffer, offset, length, position, callback)
22292239
<!-- YAML
@@ -2421,7 +2431,10 @@ changes:
24212431
* `flag` {string} See [support of file system `flags`][]. **Default:** `'r'`.
24222432
* Returns: {string|Buffer}
24232433

2424-
Synchronous version of [`fs.readFile()`][]. Returns the contents of the `path`.
2434+
Returns the contents of the `path`.
2435+
2436+
For detailed information, see the documentation of the asynchronous version of
2437+
this API: [`fs.readFile()`][].
24252438

24262439
If the `encoding` option is specified then this function returns a
24272440
string. Otherwise it returns a buffer.
@@ -2509,7 +2522,10 @@ changes:
25092522
* `position` {integer}
25102523
* Returns: {number}
25112524

2512-
Synchronous version of [`fs.read()`][]. Returns the number of `bytesRead`.
2525+
Returns the number of `bytesRead`.
2526+
2527+
For detailed information, see the documentation of the asynchronous version of
2528+
this API: [`fs.read()`][].
25132529

25142530
## fs.realpath(path[, options], callback)
25152531
<!-- YAML
@@ -2624,7 +2640,10 @@ changes:
26242640
* `encoding` {string} **Default:** `'utf8'`
26252641
* Returns: {string|Buffer}
26262642

2627-
Synchronous version of [`fs.realpath()`][]. Returns the resolved pathname.
2643+
Returns the resolved pathname.
2644+
2645+
For detailed information, see the documentation of the asynchronous version of
2646+
this API: [`fs.realpath()`][].
26282647

26292648
## fs.realpathSync.native(path[, options])
26302649
<!-- YAML
@@ -2860,7 +2879,10 @@ changes:
28602879
* `path` {string|Buffer|URL}
28612880
* `type` {string} **Default:** `'file'`
28622881

2863-
Synchronous symlink(2). Returns `undefined`.
2882+
Returns `undefined`.
2883+
2884+
For detailed information, see the documentation of the asynchronous version of
2885+
this API: [`fs.symlink()`][].
28642886

28652887
## fs.truncate(path[, len], callback)
28662888
<!-- YAML
@@ -3036,7 +3058,10 @@ changes:
30363058
* `atime` {integer}
30373059
* `mtime` {integer}
30383060

3039-
Synchronous version of [`fs.utimes()`][]. Returns `undefined`.
3061+
Returns `undefined`.
3062+
3063+
For detailed information, see the documentation of the asynchronous version of
3064+
this API: [`fs.utimes()`][].
30403065

30413066
## fs.watch(filename[, options][, listener])
30423067
<!-- YAML
@@ -3387,7 +3412,10 @@ changes:
33873412
* `mode` {integer} **Default:** `0o666`
33883413
* `flag` {string} See [support of file system `flags`][]. **Default:** `'w'`.
33893414

3390-
The synchronous version of [`fs.writeFile()`][]. Returns `undefined`.
3415+
Returns `undefined`.
3416+
3417+
For detailed information, see the documentation of the asynchronous version of
3418+
this API: [`fs.writeFile()`][].
33913419

33923420
## fs.writeSync(fd, buffer[, offset[, length[, position]]])
33933421
<!-- YAML
@@ -3423,7 +3451,10 @@ changes:
34233451
* `encoding` {string}
34243452
* Returns: {number}
34253453

3426-
Synchronous versions of [`fs.write()`][]. Returns the number of bytes written.
3454+
Returns the number of bytes written.
3455+
3456+
For detailed information, see the documentation of the asynchronous version of
3457+
this API: [`fs.write()`][].
34273458

34283459
## fs Promises API
34293460

@@ -4588,6 +4619,7 @@ the file contents.
45884619
[`fs.copyFile()`]: #fs_fs_copyfile_src_dest_flags_callback
45894620
[`fs.exists()`]: fs.html#fs_fs_exists_path_callback
45904621
[`fs.fstat()`]: #fs_fs_fstat_fd_options_callback
4622+
[`fs.ftruncate()`]: #fs_fs_ftruncate_fd_len_callback
45914623
[`fs.futimes()`]: #fs_fs_futimes_fd_atime_mtime_callback
45924624
[`fs.lstat()`]: #fs_fs_lstat_path_options_callback
45934625
[`fs.mkdir()`]: #fs_fs_mkdir_path_mode_callback
@@ -4599,6 +4631,7 @@ the file contents.
45994631
[`fs.realpath()`]: #fs_fs_realpath_path_options_callback
46004632
[`fs.rmdir()`]: #fs_fs_rmdir_path_callback
46014633
[`fs.stat()`]: #fs_fs_stat_path_options_callback
4634+
[`fs.symlink()`]: #fs_fs_symlink_target_path_type_callback
46024635
[`fs.utimes()`]: #fs_fs_utimes_path_atime_mtime_callback
46034636
[`fs.watch()`]: #fs_fs_watch_filename_options_listener
46044637
[`fs.write()`]: #fs_fs_write_fd_buffer_offset_length_position_callback

0 commit comments

Comments
 (0)