Path to the file. ~ is expanded.
Optionalmode: string | ((file: HSFile) => any)The open mode, as for hs.fs.open(). Defaults to "r"; if you omit it, pass the callback in its place.
Optionalcallback: (file: HSFile) => anyCalled with the open file. Required unless it was passed in place of mode.
Whatever callback returns, or null if the file could not be opened or no callback was given (see hs.fs.lastError).
Open a file, pass it to a function, and close it again afterwards. The file is closed when the function returns, even if it throws (in which case the exception propagates to you). The function must do all its work synchronously: an
asyncfunction would find the file already closed after its firstawait.hs.fs.withFile(path, f => ...).