From 61c243f041f2c811d6a79742304b406c9d2fb2bd Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 1 Feb 2021 11:55:12 -0800 Subject: [PATCH 1/3] fs: use a default callback for fs.close() The `fs.close()` function requires a callback. Most often the only thing that callback does is check and rethrow the error if one occurs. To eliminate common boilerplate, make the callback optional with a default that checks and rethrows the error as an uncaught exception. Signed-off-by: James M Snell --- doc/api/fs.md | 8 +++++++- lib/fs.js | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index a0a47b14398dd7..71f11a674fdaee 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1617,10 +1617,13 @@ This is the synchronous version of [`fs.chown()`][]. See also: chown(2). -## `fs.close(fd, callback)` +## `fs.close(fd[, callback])`