From 92348a9216876d274d48996664abe53c2f11880e Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 1 Feb 2021 11:55:12 -0800 Subject: [PATCH] fs: use a default callback for fs.close() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 PR-URL: https://github.com/nodejs/node/pull/37174 Reviewed-By: Juan José Arboleda Reviewed-By: Antoine du Hamel Reviewed-By: Matteo Collina Reviewed-By: Darshan Sen Reviewed-By: Benjamin Gruenbaum Reviewed-By: Zijian Liu Reviewed-By: Luigi Pinca --- doc/api/fs.md | 8 +++++++- lib/fs.js | 9 +++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index ab0cb2484094fa..42be4d84e90fa4 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1608,10 +1608,13 @@ This is the synchronous version of [`fs.chown()`][]. See also: chown(2). -## `fs.close(fd, callback)` +## `fs.close(fd[, callback])`