From a82713cbb62855d8437acd2047478d7edd1de514 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sun, 10 Apr 2022 13:35:08 +0200 Subject: [PATCH] doc: recommend `fh.createWriteStream` for fsPromises methods `fh.createWriteStream` can be more convenient than `fs.createWriteStream` when using the FS promises API. PR-URL: https://github.com/nodejs/node/pull/42653 Reviewed-By: Colin Ihrig Reviewed-By: Akhil Marsonya Reviewed-By: Mestery --- doc/api/fs.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 25731ecc1ae29f..c32c624f48b4a7 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -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 @@ -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 @@ -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 @@ -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