From 8a920185cc7a3a874e9442291f2a1506df7649cc Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 6 Sep 2021 11:33:10 +0200 Subject: [PATCH] fs: make `open` and `close` stream override optional when unused When using `createReadStream` or `createWriteStream` with a specific file descriptor or `FileHandle` instead of a path, `open` method is not used, there is no point in forcing users to provide it. When using `createReadStream` or `createWriteStream` with `autoClose` set to false, `close` method is not used, there is no point in forcing users to provide it. PR-URL: https://github.com/nodejs/node/pull/40013 Reviewed-By: James M Snell --- doc/api/fs.md | 22 ++++++- lib/internal/fs/streams.js | 114 +++++++++++++++++++------------------ 2 files changed, 77 insertions(+), 59 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 73fc9c13c3ff9d..5f713cc606088b 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1935,6 +1935,12 @@ behavior is similar to `cp dir1/ dir2/`.