From 655d19638a199fc500453f25e23d5a42779297d7 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 4a2182b86fc40d..91168a5c10ef95 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])`