From 35164fa46633ce58cda2a40ffe519e6725b2872c Mon Sep 17 00:00:00 2001 From: Colin Ihrig Date: Tue, 17 Oct 2023 21:51:41 -0400 Subject: [PATCH] fs: add flush option to appendFile() functions This commit adds documentation and tests for the 'flush' option of the fs.appendFile family of functions. Technically, support was indirectly added in #50009, but this makes it more official. Refs: https://github.com/nodejs/node/issues/49886 Refs: https://github.com/nodejs/node/pull/50009 PR-URL: https://github.com/nodejs/node/pull/50095 Reviewed-By: Matteo Collina --- doc/api/fs.md | 21 ++++ test/parallel/test-fs-append-file-flush.js | 114 +++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 test/parallel/test-fs-append-file-flush.js diff --git a/doc/api/fs.md b/doc/api/fs.md index 8442fa2a5a18b4..7a544a59593e08 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -180,6 +180,9 @@ longer be used. * `path` {string|Buffer|URL|FileHandle} filename or {FileHandle} @@ -886,6 +895,8 @@ added: v10.0.0 * `encoding` {string|null} **Default:** `'utf8'` * `mode` {integer} **Default:** `0o666` * `flag` {string} See [support of file system `flags`][]. **Default:** `'a'`. + * `flush` {boolean} If `true`, the underlying file descriptor is flushed + prior to closing it. **Default:** `false`. * Returns: {Promise} Fulfills with `undefined` upon success. Asynchronously append data to a file, creating the file if it does not yet @@ -2028,6 +2039,9 @@ the user from reading or writing to it.