Skip to content

Commit

Permalink
doc: recommend fh.createWriteStream for fsPromises methods
Browse files Browse the repository at this point in the history
`fh.createWriteStream` can be more convenient than
`fs.createWriteStream` when using the FS promises API.

PR-URL: #42653
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
  • Loading branch information
aduh95 authored and targos committed Jul 11, 2022
1 parent e76a4ae commit bdd06dc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ The promise is resolved with an object containing two properties:
It is unsafe to use `filehandle.write()` multiple times on the same file
without waiting for the promise to be resolved (or rejected). For this
scenario, use [`fs.createWriteStream()`][].
scenario, use [`filehandle.createWriteStream()`][].
On Linux, positional writes do not work when the file is opened in append mode.
The kernel ignores the position argument and always appends the data to
Expand Down Expand Up @@ -617,7 +617,7 @@ The promise is resolved with an object containing two properties:
It is unsafe to use `filehandle.write()` multiple times on the same file
without waiting for the promise to be resolved (or rejected). For this
scenario, use [`fs.createWriteStream()`][].
scenario, use [`filehandle.createWriteStream()`][].
On Linux, positional writes do not work when the file is opened in append mode.
The kernel ignores the position argument and always appends the data to
Expand Down Expand Up @@ -1520,7 +1520,7 @@ without waiting for the promise to be settled.
Similarly to `fsPromises.readFile` - `fsPromises.writeFile` is a convenience
method that performs multiple `write` calls internally to write the buffer
passed to it. For performance sensitive code consider using
[`fs.createWriteStream()`][].
[`fs.createWriteStream()`][] or [`filehandle.createWriteStream()`][].
It is possible to use an {AbortSignal} to cancel an `fsPromises.writeFile()`.
Cancelation is "best effort", and some amount of data is likely still
Expand Down Expand Up @@ -7226,6 +7226,7 @@ the file contents.
[`ReadDirectoryChangesW`]: https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-readdirectorychangesw
[`UV_THREADPOOL_SIZE`]: cli.md#uv_threadpool_sizesize
[`event ports`]: https://illumos.org/man/port_create
[`filehandle.createWriteStream()`]: #filehandlecreatewritestreamoptions
[`filehandle.writeFile()`]: #filehandlewritefiledata-options
[`fs.access()`]: #fsaccesspath-mode-callback
[`fs.accessSync()`]: #fsaccesssyncpath-mode
Expand Down

0 comments on commit bdd06dc

Please sign in to comment.