Function writeFile

  • Asynchronously writes data to a file, replacing the file if it already exists.

    The encoding option is ignored if data is a buffer.

    Parameters

    • path: PathLike | FileHandle
    • data:
          | FileContents
          | Stream
          | Iterable<string | ArrayBufferView>
          | AsyncIterable<string | ArrayBufferView>
    • Optional_options: null | BufferEncoding | ObjectEncodingOptions & {
          flag?: OpenMode | undefined;
          flush?: boolean;
          mode?: Mode | undefined;
      }

    Returns Promise<void>

    encoding Defaults to 'utf8'.

    mode Defaults to 0644.

    flag Defaults to 'w'.