Node.js module
fs/promises
The 'node:fs/promises' module provides Promise-based variants of the fs API, allowing asynchronous file operations to be performed with async/await syntax.
Functions 32
- promises.access()
Tests a user's permissions for the file or directory specified by
path. - promises.appendFile()
Asynchronously append data to a file, creating the file if it does not yet exist.
- promises.chmod()
Changes the permissions of a file.
- promises.chown()
Changes the ownership of a file.
- promises.copyFile()
Asynchronously copies
srctodest. - promises.cp()
Asynchronously copies the entire directory structure from
srctodest, including subdirectories and files. - promises.exists()
- promises.glob()
When
followSymlinksis enabled, detected symbolic link cycles are not traversed recursively. - promises.lchown()
Changes the ownership on a symbolic link.
- promises.link()
Creates a new link from the
existingPathto thenewPath. - promises.lstat()
Equivalent to
fsPromises.stat()unlesspathrefers to a symbolic link, in which case the link itself is stat-ed, not the file that it refers to. - promises.lutimes()
Changes the access and modification times of a file in the same way as
fsPromises.utimes(), with the difference that if the path refers to a symbolic link, then the … - promises.mkdir()
Asynchronously creates a directory.
- promises.mkdtemp()
Creates a unique temporary directory.
- promises.mkdtempDisposable()
The resulting Promise holds an async-disposable object whose
pathproperty holds the created directory path. - promises.open()
Opens a
FileHandle. - promises.opendir()
Asynchronously open a directory for iterative scanning.
- promises.readdir()
Reads the contents of a directory.
- promises.readFile()
Asynchronously reads the entire contents of a file.
- promises.readlink()
Reads the contents of the symbolic link referred to by
path. - promises.realpath()
Determines the actual location of
pathusing the same semantics as thefs.realpath.native()function. - promises.rename()
Renames
oldPathtonewPath. - promises.rm()
Removes files and directories (modeled on the standard POSIX
rmutility). - promises.rmdir()
Removes the directory identified by
path. - promises.stat()
- promises.statfs()
- promises.symlink()
Creates a symbolic link.
- promises.truncate()
Truncates (shortens or extends the length) of the content at
pathtolenbytes. - promises.unlink()
If
pathrefers to a symbolic link, then the link is removed without affecting the file or directory to which that link refers. - promises.utimes()
Change the file system timestamps of the object referenced by
path. - promises.watch()
Returns an async iterator that watches for changes on
filename, wherefilenameis either a file or a directory. - promises.writeFile()
Asynchronously writes data to a file, replacing the file if it already exists.
Interfaces 13
- interface CreateReadStreamOptions
- interface CreateWriteStreamOptions
- interface DisposableTempDir
- interface FileChangeInfo
- interface FileHandle
- interface FileReadResult
- interface FlagAndOpenMode
- interface PullOptions
- interface ReadableWebStreamOptions
- interface WatchOptions
- interface WatchOptionsWithBufferEncoding
- interface WatchOptionsWithStringEncoding
- interface WriterOptions