From f971106072dd020933a0a2aa250347641beab597 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 fef0e13ab4a76e..fabbb60eeed73b 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} @@ -904,6 +913,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 @@ -2052,6 +2063,9 @@ the user from reading or writing to it.