Options
All
  • Public
  • Public/Protected
  • All
Menu

fs-nextra

Index

Type aliases

BufferEncoding

BufferEncoding: "ascii" | "utf8" | "utf16le" | "ucs2" | "base64" | "latin1" | "binary" | "hex"

SymLinkType

SymLinkType: "dir" | "file" | "junction"

The type of symlink you are creating:

  • dir
  • file
  • junction
typedef

{string} SymLinkType

memberof

fsn/nextra

Functions

access

  • access(path: PathLike, mode?: number): Promise<void>
  • [fs.promises] Asynchronously tests a user's permissions for the file specified by path.

    Parameters

    • path: PathLike

      A path to a file or directory. If a URL is provided, it must use the file: protocol. URL support is experimental.

    • Optional mode: number

    Returns Promise<void>

appendFile

  • appendFile(path: PathLike | FileHandle, data: any, options?: object | string | null): Promise<void>
  • [fs.promises] Asynchronously append data to a file, creating the file if it does not exist.

    Parameters

    • path: PathLike | FileHandle
    • data: any

      The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.

    • Optional options: object | string | null

      Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag. If encoding is not supplied, the default of 'utf8' is used. If mode is not supplied, the default of 0o666 is used. If mode is a string, it is parsed as an octal integer. If flag is not supplied, the default of 'a' is used.

    Returns Promise<void>

chmod

  • chmod(path: PathLike, mode: string | number): Promise<void>
  • [fs.promises] Asynchronous chmod(2) - Change permissions of a file.

    Parameters

    • path: PathLike

      A path to a file. If a URL is provided, it must use the file: protocol.

    • mode: string | number

      A file mode. If a string is passed, it is parsed as an octal integer.

    Returns Promise<void>

chown

  • chown(path: PathLike, uid: number, gid: number): Promise<void>
  • [fs.promises] Asynchronous chown(2) - Change ownership of a file.

    Parameters

    • path: PathLike

      A path to a file. If a URL is provided, it must use the file: protocol.

    • uid: number
    • gid: number

    Returns Promise<void>

copy

  • copy(source: string, destination: string, options?: CopyOptions | CopyFilter): Promise<void>
  • Copies files from one location to another, creating all directories required to satisfy the destination path. source and destination paths.

    function

    copy

    memberof

    fsn/nextra

    Parameters

    • source: string

      The source path

    • destination: string

      The destination path

    • Default value options: CopyOptions | CopyFilter = {}

      Options for the copy, or a filter function

    Returns Promise<void>

copyFile

  • copyFile(src: PathLike, dest: PathLike, flags?: number): Promise<void>
  • [fs.promises] Asynchronously copies src to dest. By default, dest is overwritten if it already exists. Node.js makes no guarantees about the atomicity of the copy operation. If an error occurs after the destination file has been opened for writing, Node.js will attempt to remove the destination.

    Parameters

    • src: PathLike

      A path to the source file.

    • dest: PathLike

      A path to the destination file.

    • Optional flags: number

      An optional integer that specifies the behavior of the copy operation. The only supported flag is fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists.

    Returns Promise<void>

copyFileAtomic

  • copyFileAtomic(source: string, destination: string): Promise<void>
  • function

    copyFileAtomic

    memberof

    fsn/nextra

    Parameters

    • source: string

      The path to the file you want to copy

    • destination: string

      The path to the file destination

    Returns Promise<void>

createFile

  • createFile(file: string, atomic?: boolean): Promise<void>
  • Creates an empty file, making all folders required to satisfy the given file path.

    function

    createFile

    memberof

    fsn/nextra

    Parameters

    • file: string

      Path of the file you want to create

    • Default value atomic: boolean = false

      Whether the operation should run atomically

    Returns Promise<void>

createFileAtomic

  • createFileAtomic(file: string): Promise<void>
  • Creates an file copy, making all folders required to satisfy the given file path atomically.

    function

    createFileAtomic

    memberof

    fsn/nextra

    Parameters

    • file: string

      Path of the file you want to create

    Returns Promise<void>

createFileCopy

  • createFileCopy(source: string, destination: string, atomic?: boolean): Promise<void>
  • Creates an file copy, making all folders required to satisfy the given file path.

    function

    createFileCopy

    memberof

    fsn/nextra

    Parameters

    • source: string

      The path to the file you want to copy

    • destination: string

      The path to the file destination

    • Default value atomic: boolean = false

      Whether the operation should run atomically

    Returns Promise<void>

createFileCopyAtomic

  • createFileCopyAtomic(source: string, destination: string): Promise<void>
  • Creates a file copy atomically, making all folders required to satisfy the given file path.

    function

    createFileCopyAtomic

    memberof

    fsn/nextra

    Parameters

    • source: string

      The path to the file you want to copy

    • destination: string

      The path to the file destination

    Returns Promise<void>

createLink

  • createLink(source: string, destination: string, atomic?: boolean): Promise<void>
  • Creates a hard file link, making all folders required to satisfy the given file path.

    function

    createLink

    memberof

    fsn/nextra

    Parameters

    • source: string

      The source path of the file

    • destination: string

      The destination path of the file

    • Default value atomic: boolean = false

      Whether the operation should run atomically

    Returns Promise<void>

createLinkAtomic

  • createLinkAtomic(source: string, destination: string): Promise<void>
  • Creates a hard file link, making all folders required to satisfy the given file path atomically.

    function

    createLinkAtomic

    memberof

    fsn/nextra

    Parameters

    • source: string

      The source path of the file

    • destination: string

      The destination path of the file

    Returns Promise<void>

createSymlink

  • createSymlink(source: string, destination: string, atomic?: boolean): Promise<void>
  • createSymlink(source: string, destination: string, type?: SymLinkType, atomic?: boolean): Promise<void>
  • Creates a soft file link, making all folders required to satisfy the given file path.

    function

    createSymlink

    memberof

    fsn/nextra

    Parameters

    • source: string

      The source path of the file

    • destination: string

      The destination path of the file

    • Optional atomic: boolean

      Whether the operation should run atomically

    Returns Promise<void>

  • Parameters

    • source: string
    • destination: string
    • Optional type: SymLinkType
    • Optional atomic: boolean

    Returns Promise<void>

createSymlinkAtomic

  • createSymlinkAtomic(source: string, destination: string, type?: SymLinkType): Promise<void>
  • Creates a soft file link, making all folders required to satisfy the given file path atomically.

    function

    createSymlinkAtomic

    memberof

    fsn/nextra

    Parameters

    • source: string

      The source path of the file

    • destination: string

      The destination path of the file

    • Optional type: SymLinkType

      The type of symlink you are creating

    Returns Promise<void>

emptyDir

  • emptyDir(dir: string): Promise<void>
  • Deletes all directories and files within the provided directory.

    function

    emptyDir

    memberof

    fsn/nextra

    Parameters

    • dir: string

      The directory you wish to empty

    Returns Promise<void>

fchmod

  • fchmod(handle: FileHandle, mode: string | number): Promise<void>
  • [fs.promises] Asynchronous fchmod(2) - Change permissions of a file.

    Parameters

    • handle: FileHandle

      A FileHandle.

    • mode: string | number

      A file mode. If a string is passed, it is parsed as an octal integer.

    Returns Promise<void>

fchown

  • fchown(handle: FileHandle, uid: number, gid: number): Promise<void>
  • [fs.promises] Asynchronous fchown(2) - Change ownership of a file.

    Parameters

    • handle: FileHandle

      A FileHandle.

    • uid: number
    • gid: number

    Returns Promise<void>

fdatasync

  • fdatasync(handle: FileHandle): Promise<void>
  • Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.

    Parameters

    • handle: FileHandle

      A FileHandle.

    Returns Promise<void>

fstat

  • fstat(handle: FileHandle): Promise<Stats>
  • [fs.promises] Asynchronous fstat(2) - Get file status.

    Parameters

    • handle: FileHandle

      A FileHandle.

    Returns Promise<Stats>

fsync

  • fsync(handle: FileHandle): Promise<void>
  • [fs.promises] Asynchronous fsync(2) - synchronize a file's in-core state with the underlying storage device.

    Parameters

    • handle: FileHandle

      A FileHandle.

    Returns Promise<void>

ftruncate

  • ftruncate(handle: FileHandle, len?: number): Promise<void>
  • [fs.promises] Asynchronous ftruncate(2) - Truncate a file to a specified length.

    Parameters

    • handle: FileHandle

      A FileHandle.

    • Optional len: number

      If not specified, defaults to 0.

    Returns Promise<void>

futimes

  • futimes(handle: FileHandle, atime: string | number | Date, mtime: string | number | Date): Promise<void>
  • [fs.promises] Asynchronously change file timestamps of the file referenced by the supplied FileHandle.

    Parameters

    • handle: FileHandle

      A FileHandle.

    • atime: string | number | Date

      The last access time. If a string is provided, it will be coerced to number.

    • mtime: string | number | Date

      The last modified time. If a string is provided, it will be coerced to number.

    Returns Promise<void>

gzip

  • gzip(fileName: string, inputFile: string, atomic?: boolean): Promise<void>
  • Un-Gzips a file

    function

    gunzip

    memberof

    fsn/nextra

    Parameters

    • fileName: string

      The filename of the archive

    • inputFile: string

      The filepath of the input file

    • Default value atomic: boolean = false

      If the gzip file should be created

    Returns Promise<void>

gzipAtomic

  • gzipAtomic(fileName: string, inputFile: string): Promise<void>
  • Un-Gzips a file atomically.

    function

    gunzipAtomic

    memberof

    fsn/nextra

    Parameters

    • fileName: string

      The filename of the archive

    • inputFile: string

      The filepath of the input file

    Returns Promise<void>

lchmod

  • lchmod(path: PathLike, mode: string | number): Promise<void>
  • [fs.promises] Asynchronous lchmod(2) - Change permissions of a file. Does not dereference symbolic links.

    Parameters

    • path: PathLike

      A path to a file. If a URL is provided, it must use the file: protocol.

    • mode: string | number

      A file mode. If a string is passed, it is parsed as an octal integer.

    Returns Promise<void>

lchown

  • lchown(path: PathLike, uid: number, gid: number): Promise<void>
  • [fs.promises] Asynchronous lchown(2) - Change ownership of a file. Does not dereference symbolic links.

    Parameters

    • path: PathLike

      A path to a file. If a URL is provided, it must use the file: protocol.

    • uid: number
    • gid: number

    Returns Promise<void>

link

  • link(existingPath: PathLike, newPath: PathLike): Promise<void>
  • [fs.promises] Asynchronous link(2) - Create a new link (also known as a hard link) to an existing file.

    Parameters

    • existingPath: PathLike

      A path to a file. If a URL is provided, it must use the file: protocol.

    • newPath: PathLike

      A path to a file. If a URL is provided, it must use the file: protocol.

    Returns Promise<void>

linkAtomic

  • linkAtomic(source: string, destination: string): Promise<void>
  • Creates a hard file link atomically.

    function

    linkAtomic

    memberof

    fsn/nextra

    Parameters

    • source: string

      The source path of the file

    • destination: string

      The destination path of the file

    Returns Promise<void>

lstat

  • lstat(path: PathLike): Promise<Stats>
  • [fs.promises] Asynchronous lstat(2) - Get file status. Does not dereference symbolic links.

    Parameters

    • path: PathLike

      A path to a file. If a URL is provided, it must use the file: protocol.

    Returns Promise<Stats>

mkdir

  • [fs.promises] Asynchronous mkdir(2) - create a directory.

    Parameters

    • path: PathLike

      A path to a file. If a URL is provided, it must use the file: protocol.

    • Optional options: number | string | MakeDirectoryOptions | null

      Either the file mode, or an object optionally specifying the file mode and whether parent folders should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to 0o777.

    Returns Promise<void>

mkdirs

  • mkdirs(path: string, options?: MkdirsOptions | number): Promise<void>
  • Recursively makes directories, until the directory passed exists.

    function

    mkdirs

    memberof

    fsn/nextra

    Parameters

    • path: string

      The path you wish to make

    • Optional options: MkdirsOptions | number

      Options for making the directories

    Returns Promise<void>

mkdtemp

  • mkdtemp(prefix: string, options?: object | BufferEncoding | null): Promise<string>
  • mkdtemp(prefix: string, options: object | "buffer"): Promise<Buffer>
  • [fs.promises] Asynchronously creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory.

    Parameters

    • prefix: string
    • Optional options: object | BufferEncoding | null

      The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used.

    Returns Promise<string>

  • Parameters

    • prefix: string
    • options: object | "buffer"

    Returns Promise<Buffer>

move

  • move(source: string, destination: string, options?: MoveOptions): Promise<void>
  • function

    move

    memberof

    fsn/nextra

    Parameters

    • source: string

      The source path of the file

    • destination: string

      The destination path of the file

    • Default value options: MoveOptions = {}

      The options for the move

    Returns Promise<void>

open

  • open(path: PathLike, flags: string | number, mode?: string | number): Promise<FileHandle>
  • [fs.promises] Asynchronous open(2) - open and possibly create a file.

    Parameters

    • path: PathLike

      A path to a file. If a URL is provided, it must use the file: protocol.

    • flags: string | number
    • Optional mode: string | number

      A file mode. If a string is passed, it is parsed as an octal integer. If not supplied, defaults to 0o666.

    Returns Promise<FileHandle>

outputFile

  • outputFile(file: string, data: string | Buffer | Uint8Array, atomic?: boolean): Promise<void>
  • outputFile(file: string, data: string | Buffer | Uint8Array, options?: WriteOptions | string, atomic?: boolean): Promise<void>
  • Writes a file to disk, creating all directories needed to meet the filepath provided.

    function

    outputFile

    memberof

    fsn/nextra

    Parameters

    • file: string

      The path to the file you want to create

    • data: string | Buffer | Uint8Array

      The data to write to file

    • Optional atomic: boolean

    Returns Promise<void>

  • Parameters

    • file: string
    • data: string | Buffer | Uint8Array
    • Optional options: WriteOptions | string
    • Optional atomic: boolean

    Returns Promise<void>

outputFileAtomic

  • outputFileAtomic(file: string, data: string | Buffer | Uint8Array, options?: WriteOptions | string): Promise<void>
  • Writes a file to disk, creating all directories needed to meet the filepath provided atomically.

    function

    outputFileAtomic

    memberof

    fsn/nextra

    Parameters

    • file: string

      The path to the file you want to create

    • data: string | Buffer | Uint8Array

      The data to write to file

    • Optional options: WriteOptions | string

      The write options or the encoding string.

    Returns Promise<void>

outputJSON

  • outputJSON(file: string, data: any, atomic?: boolean): Promise<void>
  • outputJSON(file: string, data: any, options?: JsonOptions, atomic?: boolean): Promise<void>
  • Writes a json file to disk, creating all directories needed to meet the filepath provided.

    function

    outputJSON

    memberof

    fsn/nextra

    Parameters

    • file: string

      The path to the file you want to create

    • data: any

      The data to write to file

    • Optional atomic: boolean

      If the operation should be done atomically

    Returns Promise<void>

  • Parameters

    • file: string
    • data: any
    • Optional options: JsonOptions
    • Optional atomic: boolean

    Returns Promise<void>

outputJSONAtomic

  • outputJSONAtomic(file: string, data: any, options?: JsonOptions): Promise<void>
  • Writes a json file to disk, creating all directories needed to meet the filepath provided atomically.

    function

    outputJSONAtomic

    memberof

    fsn/nextra

    Parameters

    • file: string

      The path to the file you want to create

    • data: any

      The data to write to file

    • Optional options: JsonOptions

      The write options or the encoding string.

    Returns Promise<void>

pathExists

  • pathExists(path: string): Promise<boolean>
  • Checks if a path exists.

    function

    pathExists

    memberof

    fsn/nextra

    Parameters

    • path: string

      The path to check

    Returns Promise<boolean>

read

  • read<TBuffer>(handle: FileHandle, buffer: TBuffer, offset?: number | null, length?: number | null, position?: number | null): Promise<object>
  • [fs.promises] Asynchronously reads data from the file referenced by the supplied FileHandle.

    Type parameters

    • TBuffer: Buffer | Uint8Array

    Parameters

    • handle: FileHandle

      A FileHandle.

    • buffer: TBuffer

      The buffer that the data will be written to.

    • Optional offset: number | null

      The offset in the buffer at which to start writing.

    • Optional length: number | null

      The number of bytes to read.

    • Optional position: number | null

      The offset from the beginning of the file from which data should be read. If null, data will be read from the current position.

    Returns Promise<object>

readFile

  • readFile(path: PathLike | FileHandle, options?: object | null): Promise<Buffer>
  • readFile(path: PathLike | FileHandle, options?: object | BufferEncoding): Promise<string>
  • [fs.promises] Asynchronously reads the entire contents of a file.

    Parameters

    • path: PathLike | FileHandle

      A path to a file. If a URL is provided, it must use the file: protocol. If a FileHandle is provided, the underlying file will not be closed automatically.

    • Optional options: object | null

      An object that may contain an optional flag. If a flag is not provided, it defaults to 'r'.

    Returns Promise<Buffer>

  • Parameters

    • path: PathLike | FileHandle
    • Optional options: object | BufferEncoding

    Returns Promise<string>

readJSON

  • readJSON(file: string, options?: ReadJSONOptions | BufferEncoding): Promise<any>
  • Reads a file and parses it into a javascript object.

    function

    readJSON

    memberof

    fsn/nextra

    Parameters

    • file: string

      The file path to the json file

    • Default value options: ReadJSONOptions | BufferEncoding = { flag: 'r' }

    Returns Promise<any>

readdir

  • readdir(path: PathLike, options?: object | BufferEncoding | null): Promise<string[]>
  • readdir(path: PathLike, options: object | "buffer"): Promise<Buffer[]>
  • [fs.promises] Asynchronous readdir(3) - read a directory.

    Parameters

    • path: PathLike

      A path to a file. If a URL is provided, it must use the file: protocol.

    • Optional options: object | BufferEncoding | null

      The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used.

    Returns Promise<string[]>

  • Parameters

    • path: PathLike
    • options: object | "buffer"

    Returns Promise<Buffer[]>

readlink

  • readlink(path: PathLike, options?: object | BufferEncoding | null): Promise<string>
  • readlink(path: PathLike, options: object | "buffer"): Promise<Buffer>
  • [fs.promises] Asynchronous readlink(2) - read value of a symbolic link.

    Parameters

    • path: PathLike

      A path to a file. If a URL is provided, it must use the file: protocol.

    • Optional options: object | BufferEncoding | null

      The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used.

    Returns Promise<string>

  • Parameters

    • path: PathLike
    • options: object | "buffer"

    Returns Promise<Buffer>

realpath

  • realpath(path: PathLike, options?: object | BufferEncoding | null): Promise<string>
  • realpath(path: PathLike, options: object | "buffer"): Promise<Buffer>
  • [fs.promises] Asynchronous realpath(3) - return the canonicalized absolute pathname.

    Parameters

    • path: PathLike

      A path to a file. If a URL is provided, it must use the file: protocol.

    • Optional options: object | BufferEncoding | null

      The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, 'utf8' is used.

    Returns Promise<string>

  • Parameters

    • path: PathLike
    • options: object | "buffer"

    Returns Promise<Buffer>

remove

  • remove(path: string, options?: RemoveOptions): Promise<void>
  • Removes a single file or single directory with no children.

    function

    remove

    memberof

    fsn/nextra

    Parameters

    • path: string

      The path to remove

    • Default value options: RemoveOptions = {}

      The remove options

    Returns Promise<void>

rename

  • rename(oldPath: PathLike, newPath: PathLike): Promise<void>
  • [fs.promises] Asynchronous rename(2) - Change the name or location of a file or directory.

    Parameters

    • oldPath: PathLike

      A path to a file. If a URL is provided, it must use the file: protocol. URL support is experimental.

    • newPath: PathLike

      A path to a file. If a URL is provided, it must use the file: protocol. URL support is experimental.

    Returns Promise<void>

rmdir

  • rmdir(path: PathLike): Promise<void>
  • [fs.promises] Asynchronous rmdir(2) - delete a directory.

    Parameters

    • path: PathLike

      A path to a file. If a URL is provided, it must use the file: protocol.

    Returns Promise<void>

scan

  • scan(root: string, options?: ScanOptions): Promise<Map<string, Stats>>
  • Recursively scans a directory, returning a map of stats keyed on the full path to the item.

    function

    scan

    memberof

    fsn/nextra

    Parameters

    • root: string

      The path to scan

    • Default value options: ScanOptions = {}

      The options for the scan

    Returns Promise<Map<string, Stats>>

stat

  • stat(path: PathLike): Promise<Stats>
  • [fs.promises] Asynchronous stat(2) - Get file status.

    Parameters

    • path: PathLike

      A path to a file. If a URL is provided, it must use the file: protocol.

    Returns Promise<Stats>

symlink

  • symlink(target: PathLike, path: PathLike, type?: string | null): Promise<void>
  • [fs.promises] Asynchronous symlink(2) - Create a new symbolic link to an existing file.

    Parameters

    • target: PathLike

      A path to an existing file. If a URL is provided, it must use the file: protocol.

    • path: PathLike

      A path to the new symlink. If a URL is provided, it must use the file: protocol.

    • Optional type: string | null

      May be set to 'dir', 'file', or 'junction' (default is 'file') and is only available on Windows (ignored on other platforms). When using 'junction', the target argument will automatically be normalized to an absolute path.

    Returns Promise<void>

symlinkAtomic

  • symlinkAtomic(source: string, destination: string, type?: SymLinkType): Promise<void>
  • Creates a soft file link atomically.

    function

    symlinkAtomic

    memberof

    fsn/nextra

    Parameters

    • source: string

      The source path of the file

    • destination: string

      The destination path of the file

    • Optional type: SymLinkType

      The type of symlink you are creating

    Returns Promise<void>

targz

  • targz(fileName: string, inputFiles: string | string[], atomic?: boolean): Promise<void>
  • Tar/Gzips a directory or array of files.

    function

    targz

    memberof

    fsn/nextra

    Parameters

    • fileName: string

      The filename of the archive

    • inputFiles: string | string[]

      The directory or array of filepaths to .tar.gz

    • Default value atomic: boolean = false

    Returns Promise<void>

targzAtomic

  • targzAtomic(fileName: string, inputFiles: string | string[]): Promise<void>
  • Tar/Gzips a directory or array of files.

    function

    targzAtomic

    memberof

    fsn/nextra

    Parameters

    • fileName: string

      The filename of the archive

    • inputFiles: string | string[]

      The directory or array of filepaths to .tar.gz

    Returns Promise<void>

truncate

  • truncate(path: PathLike, len?: number): Promise<void>
  • [fs.promises] Asynchronous truncate(2) - Truncate a file to a specified length.

    Parameters

    • path: PathLike

      A path to a file. If a URL is provided, it must use the file: protocol.

    • Optional len: number

      If not specified, defaults to 0.

    Returns Promise<void>

unTargz

  • unTargz(outputDirectory: string, inputFile: string, atomic?: boolean): Promise<void>
  • Extracts files from .tar.gz archives.

    function

    unTargz

    memberof

    fsn/nextra

    Parameters

    • outputDirectory: string

      The directory to extract to

    • inputFile: string

      The archive file

    • Default value atomic: boolean = false

      The if the writes should be atomic

    Returns Promise<void>

unTargzAtomic

  • unTargzAtomic(outputDirectory: string, inputFile: string): Promise<void>
  • Extracts files from .tar.gz archives and writes them atomically.

    function

    unTargzAtomic

    memberof

    fsn/nextra

    Parameters

    • outputDirectory: string

      The directory to extract to

    • inputFile: string

      The archive file

    Returns Promise<void>

unlink

  • unlink(path: PathLike): Promise<void>
  • [fs.promises] Asynchronous unlink(2) - delete a name and possibly the file it refers to.

    Parameters

    • path: PathLike

      A path to a file. If a URL is provided, it must use the file: protocol.

    Returns Promise<void>

utimes

  • utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise<void>
  • [fs.promises] Asynchronously change file timestamps of the file referenced by the supplied path.

    Parameters

    • path: PathLike

      A path to a file. If a URL is provided, it must use the file: protocol.

    • atime: string | number | Date

      The last access time. If a string is provided, it will be coerced to number.

    • mtime: string | number | Date

      The last modified time. If a string is provided, it will be coerced to number.

    Returns Promise<void>

write

  • write<TBuffer>(handle: FileHandle, buffer: TBuffer, offset?: number | null, length?: number | null, position?: number | null): Promise<object>
  • write(handle: FileHandle, data: any, position?: number | null, encoding?: string | null): Promise<object>
  • [fs.promises] Asynchronously writes buffer to the file referenced by the supplied FileHandle. It is unsafe to call fsPromises.write() multiple times on the same file without waiting for the Promise to be resolved (or rejected). For this scenario, fs.createWriteStream is strongly recommended.

    Type parameters

    • TBuffer: Buffer | Uint8Array

    Parameters

    • handle: FileHandle

      A FileHandle.

    • buffer: TBuffer

      The buffer that the data will be written to.

    • Optional offset: number | null

      The part of the buffer to be written. If not supplied, defaults to 0.

    • Optional length: number | null

      The number of bytes to write. If not supplied, defaults to buffer.length - offset.

    • Optional position: number | null

      The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.

    Returns Promise<object>

  • [fs.promises] Asynchronously writes string to the file referenced by the supplied FileHandle. It is unsafe to call fsPromises.write() multiple times on the same file without waiting for the Promise to be resolved (or rejected). For this scenario, fs.createWriteStream is strongly recommended.

    Parameters

    • handle: FileHandle

      A FileHandle.

    • data: any

      A string to write. If something other than a string is supplied it will be coerced to a string.

    • Optional position: number | null

      The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.

    • Optional encoding: string | null

      The expected string encoding.

    Returns Promise<object>

writeFile

  • writeFile(path: PathLike | FileHandle, data: any, options?: object | string | null): Promise<void>
  • [fs.promises] Asynchronously writes data to a file, replacing the file if it already exists. It is unsafe to call fsPromises.writeFile() multiple times on the same file without waiting for the Promise to be resolved (or rejected).

    Parameters

    • path: PathLike | FileHandle

      A path to a file. If a URL is provided, it must use the file: protocol. URL support is experimental. If a FileHandle is provided, the underlying file will not be closed automatically.

    • data: any

      The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.

    • Optional options: object | string | null

      Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag. If encoding is not supplied, the default of 'utf8' is used. If mode is not supplied, the default of 0o666 is used. If mode is a string, it is parsed as an octal integer. If flag is not supplied, the default of 'w' is used.

    Returns Promise<void>

writeFileAtomic

  • writeFileAtomic(file: string, data: string | Buffer | Uint8Array, options?: WriteOptions | string): Promise<void>
  • function

    writeFileAtomic

    memberof

    fsn/nextra

    Parameters

    • file: string

      The path to the file you want to create

    • data: string | Buffer | Uint8Array

      The data to write to file

    • Optional options: WriteOptions | string

      The write options or the encoding string.

    Returns Promise<void>

writeJSON

  • writeJSON(file: string, object: any, atomic?: boolean): Promise<void>
  • writeJSON(file: string, object: any, options?: JsonOptions, atomic?: boolean): Promise<void>
  • Writes a Javascript Object to file as JSON.

    function

    writeJSON

    memberof

    fsn/nextra

    Parameters

    • file: string

      The path to the file you want to create

    • object: any

      The javascript object you would like to write to file

    • Optional atomic: boolean

    Returns Promise<void>

  • Parameters

    • file: string
    • object: any
    • Optional options: JsonOptions
    • Optional atomic: boolean

    Returns Promise<void>

writeJSONAtomic

  • writeJSONAtomic(file: string, object: any, options?: JsonOptions): Promise<void>
  • Writes a Javascript Object to file as JSON atomically.

    function

    writeJSONAtomic

    memberof

    fsn/nextra

    Parameters

    • file: string

      The path to the file you want to create

    • object: any

      The javascript object you would like to write to file

    • Default value options: JsonOptions = {}

      The options to pass JSON.stringify and writeFile

    Returns Promise<void>

Generated using TypeDoc