From 7d0f680aafb976927f44c2de375854baeafe21da 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 acee67c11ea350..13a51cdc8add33 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])`