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: nodejs#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 xtx1130 committed Apr 25, 2022
1 parent 6a7e0d6 commit dcee393
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 @@ -613,7 +613,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 @@ -648,7 +648,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 @@ -1547,7 +1547,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 @@ -7471,6 +7471,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 dcee393

Please sign in to comment.