Skip to content

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.

fs.close(fd);

// is equivalent to

fs.close(fd, (err) => {
  if (err != null) throw err;
});

/cc @mcollina

Signed-off-by: James M Snell jasnell@gmail.com

Merge request reports

Loading