Skip to content

Commit 3e7b3e3

Browse files
benglMylesBorins
authored andcommitted
doc: correct filehandle.[read|write|append]File()
* Remove `mode` and `flag` options for all three functions, since they all ignore those options. * Remove mention of `path` argument for `readFile`, since it isn't actually an option to this method. * Clarify that for file handles, `appendFile` and `writeFile` are equivalent. PR-URL: #31235 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
1 parent 57016b9 commit 3e7b3e3

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

doc/api/fs.md

+6-16
Original file line numberDiff line numberDiff line change
@@ -4253,17 +4253,13 @@ added: v10.0.0
42534253
* `data` {string|Buffer}
42544254
* `options` {Object|string}
42554255
* `encoding` {string|null} **Default:** `'utf8'`
4256-
* `mode` {integer} **Default:** `0o666`
4257-
* `flag` {string} See [support of file system `flags`][]. **Default:** `'a'`.
42584256
* Returns: {Promise}
42594257

4260-
Asynchronously append data to this file, creating the file if it does not yet
4261-
exist. `data` can be a string or a [`Buffer`][]. The `Promise` will be
4262-
resolved with no arguments upon success.
4258+
Alias of [`filehandle.writeFile()`][].
42634259

4264-
If `options` is a string, then it specifies the encoding.
4265-
4266-
The `FileHandle` must have been opened for appending.
4260+
When operating on file handles, the mode cannot be changed from what it was set
4261+
to with [`fsPromises.open()`][]. Therefore, this is equivalent to
4262+
[`filehandle.writeFile()`][].
42674263

42684264
#### `filehandle.chmod(mode)`
42694265
<!-- YAML
@@ -4364,7 +4360,6 @@ added: v10.0.0
43644360

43654361
* `options` {Object|string}
43664362
* `encoding` {string|null} **Default:** `null`
4367-
* `flag` {string} See [support of file system `flags`][]. **Default:** `'r'`.
43684363
* Returns: {Promise}
43694364

43704365
Asynchronously reads the entire contents of a file.
@@ -4375,11 +4370,6 @@ object. Otherwise, the data will be a string.
43754370

43764371
If `options` is a string, then it specifies the encoding.
43774372

4378-
When the `path` is a directory, the behavior of `fsPromises.readFile()` is
4379-
platform-specific. On macOS, Linux, and Windows, the promise will be rejected
4380-
with an error. On FreeBSD, a representation of the directory's contents will be
4381-
returned.
4382-
43834373
The `FileHandle` has to support reading.
43844374

43854375
If one or more `filehandle.read()` calls are made on a file handle and then a
@@ -4569,8 +4559,6 @@ added: v10.0.0
45694559
* `data` {string|Buffer|Uint8Array}
45704560
* `options` {Object|string}
45714561
* `encoding` {string|null} **Default:** `'utf8'`
4572-
* `mode` {integer} **Default:** `0o666`
4573-
* `flag` {string} See [support of file system `flags`][]. **Default:** `'w'`.
45744562
* Returns: {Promise}
45754563

45764564
Asynchronously writes data to a file, replacing the file if it already exists.
@@ -5545,6 +5533,7 @@ the file contents.
55455533
[`UV_THREADPOOL_SIZE`]: cli.html#cli_uv_threadpool_size_size
55465534
[`WriteStream`]: #fs_class_fs_writestream
55475535
[`event ports`]: https://illumos.org/man/port_create
5536+
[`filehandle.writeFile()`]: #fs_filehandle_writefile_data_options
55485537
[`fs.Dir`]: #fs_class_fs_dir
55495538
[`fs.Dirent`]: #fs_class_fs_dirent
55505539
[`fs.FSWatcher`]: #fs_class_fs_fswatcher
@@ -5579,6 +5568,7 @@ the file contents.
55795568
[`fs.write(fd, string...)`]: #fs_fs_write_fd_string_position_encoding_callback
55805569
[`fs.writeFile()`]: #fs_fs_writefile_file_data_options_callback
55815570
[`fs.writev()`]: #fs_fs_writev_fd_buffers_position_callback
5571+
[`fsPromises.open()`]: #fs_fspromises_open_path_flags_mode
55825572
[`fsPromises.opendir()`]: #fs_fspromises_opendir_path_options
55835573
[`inotify(7)`]: http://man7.org/linux/man-pages/man7/inotify.7.html
55845574
[`kqueue(2)`]: https://www.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2

0 commit comments

Comments
 (0)