Path to the JSON file.
Data to be stringified and written to the file.
Optional
options: {Options for writing the file and stringifying JSON.
Optional
charsetEncoding?: stringThe character set encoding of the file.
Defaults to "utf-8".
Optional
endOfLine?: null | "\n" | "\r\n"The line ending style of the file.
If null
, the stringifier default is used.
Defaults to null
.
Optional
finalNewline?: null | booleanWhether the file should end with a newline.
If null
, the stringifier default is used.
Defaults to null
.
Optional
flag?: OpenModeOptional
flush?: booleanIf all data is successfully written to the file, and flush
is true
, filehandle.sync()
is used to flush the data.
Optional
indentation?: stringThe indentation string of the JSON file.
Defaults to an empty string (no indentation).
Optional
mode?: ModeOptional
replacer?: JsonReplacerA function that alters the behavior of the stringification process.
See MDN for more information.
Optional
signal?: null | AbortSignalWhen provided the corresponding AbortController
can be used to cancel an asynchronous action.
Optional
trimTrailingWhitespace?: null | booleanWhether to trim trailing whitespace when writing the file.
If null
, the stringifier default is used.
Defaults to null
.
A promise that resolves when the file has been written.
Writes a JSON file by stringifying the provided data.