From 7bde4c6c8bc3da99255387197ef19a3110e1396c Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sun, 8 Oct 2023 17:58:50 -0400 Subject: [PATCH] fs: add flush option to createWriteStream() This commit adds a 'flush' option to the createWriteStream() family of functions. Refs: https://github.com/nodejs/node/issues/49886 --- doc/api/fs.md | 11 +++ lib/fs.js | 1 + lib/internal/fs/promises.js | 1 + lib/internal/fs/streams.js | 26 ++++++- test/parallel/test-fs-write-stream-flush.js | 81 +++++++++++++++++++++ 5 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 test/parallel/test-fs-write-stream-flush.js diff --git a/doc/api/fs.md b/doc/api/fs.md index f8390de7182702..ed6f5f16c0bfd9 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -318,6 +318,10 @@ fd.createReadStream({ start: 90, end: 99 }); * `options` {Object} @@ -326,6 +330,8 @@ added: v16.11.0 * `emitClose` {boolean} **Default:** `true` * `start` {integer} * `highWaterMark` {number} **Default:** `16384` + * `flush` {boolean} If `true`, the underlying file descriptor is flushed + prior to closing it. **Default:** `false`. * Returns: {fs.WriteStream} `options` may also include a `start` option to allow writing data at some @@ -2538,6 +2544,9 @@ If `options` is a string, then it specifies the encoding.