From 254514c0310155c6dfbd8480820af0166ce55fde 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 | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index cac35be697c483..2f9e2972cb8a51 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1618,10 +1618,13 @@ This is the synchronous version of [`fs.chown()`][]. See also: chown(2). -## `fs.close(fd, callback)` +## `fs.close(fd[, callback])`