From 9a8cc22736eb073f268ddf7345103948cf0d8af2 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sun, 8 Oct 2023 19:21:53 -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 --- 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 f8390de7182702..2337cc15c16d22 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} @@ -898,6 +907,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 @@ -2044,6 +2055,9 @@ the user from reading or writing to it.