• Converts a JavaScript value to a JavaScript Object Notation (JSON) string, and asynchronously writes data to a file, replacing the file if it already exists.

    Parameters

    • file: PathLike | FileHandle

      filename or FileHandle

    • obj: any

      A JavaScript value, usually an object or array, to be converted.

    • Optionaloptions: BufferEncoding | ObjectEncodingOptions & {
          flag?: OpenMode;
          mode?: Mode;
      } & Abortable
    • Optionalreplacer: Replacer<any>

      A function that transforms the results.

    • Optionalspace: string | number

      Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.

    Returns Promise<void>